Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-creates

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-creates - npm Package Compare versions

Comparing version 1.0.14 to 1.0.15

dist/scripts/clean-cache/clean-cache.d.ts

9

CHANGELOG.md

@@ -7,2 +7,11 @@ ### Changelog

#### [v1.0.15](https://github.com/tzachbon/react-creates/compare/v1.0.14...v1.0.15)
> 25 August 2020
- Caching values #13 [`#18`](https://github.com/tzachbon/react-creates/pull/18)
- feat(vsc): `skipTest` [`00c9f32`](https://github.com/tzachbon/react-creates/commit/00c9f32c3f615bd2158b04e6040096d0c681e914)
- fix(vsc): using `npx` [`a3b6096`](https://github.com/tzachbon/react-creates/commit/a3b609609d55caae509f4aa10cae97acac901556)
- types(cli): component type fix [`2d96677`](https://github.com/tzachbon/react-creates/commit/2d96677c3f43f5bc2cba77317d66d04ae541e696)
#### [v1.0.14](https://github.com/tzachbon/react-creates/compare/v1.0.13...v1.0.14)

@@ -9,0 +18,0 @@

1

dist/index.d.ts

@@ -0,2 +1,3 @@

export * from './utils/config';
export * from './scripts/component/parsers';
export * from './scripts/component';

@@ -13,4 +13,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./utils/config"), exports);
__exportStar(require("./scripts/component/parsers"), exports);
__exportStar(require("./scripts/component"), exports);
//# sourceMappingURL=index.js.map

3

dist/react-creates.js

@@ -6,3 +6,4 @@ #!/usr/bin/env node

const component_1 = require("./scripts/component");
commander_1.program.addCommand(component_1.createComponent()).parse(process.argv);
const clean_cache_1 = require("./scripts/clean-cache/clean-cache");
commander_1.program.addCommand(component_1.createComponent()).addCommand(clean_cache_1.cleanCache()).parse(process.argv);
//# sourceMappingURL=react-creates.js.map

@@ -0,18 +1,20 @@

import { Styles } from './parsers/parse-style';
import { Language } from './parsers/parse-language';
import { Styles } from './parsers/parse-style';
import { Types } from './parsers/parse-type';
export declare const createComponent: () => import("commander").Command;
export interface CreateComponent {
type: Types;
language: Language;
style: Styles;
scss: boolean;
css: boolean;
sass: boolean;
propTypes: boolean;
skipTest: boolean;
function: boolean;
directory: string;
class: boolean;
type?: Types;
language?: Language;
style?: Styles;
scss?: boolean;
css?: boolean;
sass?: boolean;
propTypes?: boolean;
skipTest?: boolean;
function?: boolean;
directory?: string;
class?: boolean;
ignoreCache?: boolean;
skipCache?: boolean;
}
export declare const createComponentRaw: (name: string, { type, language, style, scss, css, sass, propTypes, skipTest, function: func, directory: target, class: klass, }: CreateComponent) => Promise<void>;
export declare const createComponentRaw: (name: string, { type, language, style, scss, css, sass, propTypes, skipTest, function: func, directory: target, class: klass, skipCache, ignoreCache, }: CreateComponent) => Promise<void>;

@@ -8,11 +8,13 @@ "use strict";

const commander_1 = require("commander");
const parse_language_1 = require("./parsers/parse-language");
const chalk_1 = __importDefault(require("chalk"));
const config_1 = __importDefault(require("../../utils/config"));
const run_1 = require("./run");
const options_logger_1 = require("./options-logger");
const error_1 = require("../../utils/error");
const parse_prop_types_1 = require("./parsers/parse-prop-types");
const parse_skip_test_1 = require("./parsers/parse-skip-test");
const parse_style_1 = require("./parsers/parse-style");
const parse_target_1 = require("./parsers/parse-target");
const parse_language_1 = require("./parsers/parse-language");
const parse_type_1 = require("./parsers/parse-type");
const run_1 = require("./run");
const chalk_1 = __importDefault(require("chalk"));
const options_logger_1 = require("./options-logger");
const parse_prop_types_1 = require("./parsers/parse-prop-types");
const error_1 = require("../../utils/error");
exports.createComponent = () => commander_1.program

@@ -26,3 +28,3 @@ .command('component <name>')

.option('-d --directory <target>', 'Component directory', process.cwd())
.option('-t --type <component>', parse_type_1.TYPE_MESSAGE, parse_type_1.Types.FUNCTION)
.option('-t --type <component>', parse_type_1.TYPE_MESSAGE)
.option('-pt --prop-types', 'Should add Prop-types if inside javascript project')

@@ -32,5 +34,10 @@ .option('-f --function', 'Generate function component')

.option('--skip-test', 'Will not create test file')
.option('-s --style <styling>', 'Selected the style', parse_style_1.Styles.CSS)
.action(async (name, _) => await exports.createComponentRaw(name, _.opts()));
exports.createComponentRaw = async (name, { type, language, style, scss, css, sass, propTypes, skipTest, function: func, directory: target, class: klass, }) => {
.option('-s --style <styling>', 'Selected the style')
.option('--ignore-cache', "Won't use cache values")
.option('--skip-cache', "Won't save cache values")
.action(async (name, _) => {
await exports.createComponentRaw(name, _.opts());
});
exports.createComponentRaw = async (name, { type, language, style, scss, css, sass, propTypes, skipTest, function: func, directory: target, class: klass, skipCache, ignoreCache, }) => {
const config = await config_1.default({ target, skipCache });
const styles = { scss, css, sass };

@@ -60,7 +67,7 @@ for (const [styleName, isOn] of Object.entries(styles)) {

target,
type: await parse_type_1.parseTypes(type),
language: await parse_language_1.parseLanguage({ language, target }),
style: await parse_style_1.parseStyle(style),
propTypes: await parse_prop_types_1.parsePropTypes({ propTypes, target }),
skipTest: Boolean(skipTest),
type: await parse_type_1.parseTypes({ type, config, ignoreCache }),
language: await parse_language_1.parseLanguage({ language, target, config, ignoreCache }),
style: await parse_style_1.parseStyle({ style, config, ignoreCache }),
propTypes: await parse_prop_types_1.parsePropTypes({ propTypes, target, config, ignoreCache }),
skipTest: await parse_skip_test_1.parseSkipTest({ skipTest, config, ignoreCache }),
};

@@ -67,0 +74,0 @@ options_logger_1.optionsLogger(options);

@@ -6,1 +6,2 @@ export * from './parse-language';

export * from './parse-type';
export * from './keys';

@@ -18,2 +18,3 @@ "use strict";

__exportStar(require("./parse-type"), exports);
__exportStar(require("./keys"), exports);
//# sourceMappingURL=index.js.map

@@ -0,1 +1,2 @@

import { WithConfig } from '../../../utils/config';
export declare enum Language {

@@ -5,6 +6,8 @@ TYPESCRIPT = "typescript",

}
export declare const LANGUAGE_MESSAGE: string;
export declare function parseLanguage({ language, target }: {
interface Params extends WithConfig {
language: Language;
target: string;
}): Promise<Language>;
}
export declare const LANGUAGE_MESSAGE: string;
export declare function parseLanguage({ language, target, config, ignoreCache }: Params): Promise<Language>;
export {};

@@ -8,2 +8,4 @@ "use strict";

const is_typescript_1 = __importDefault(require("../../../utils/is-typescript"));
const lodash_1 = require("lodash");
const keys_1 = require("./keys");
var Language;

@@ -14,12 +16,18 @@ (function (Language) {

})(Language = exports.Language || (exports.Language = {}));
const KEY = keys_1.PARSE_KEYS.LANGUAGE;
exports.LANGUAGE_MESSAGE = `Select the language you want the component to be created. (${Language.TYPESCRIPT} or ${Language.JAVASCRIPT})`;
async function parseLanguage({ language, target }) {
return typeof language === "string" &&
Object.values(Language).includes(language)
? language
: (await is_typescript_1.default(target))
? Language.TYPESCRIPT
: Language.JAVASCRIPT;
async function parseLanguage({ language, target, config, ignoreCache }) {
const hasAskedForLanguage = lodash_1.isString(language) && Object.values(Language).includes(language);
if (hasAskedForLanguage) {
return config.set(KEY, language);
}
else if (!ignoreCache && config.has(KEY)) {
return config.get(KEY);
}
else {
language = (await is_typescript_1.default(target)) ? Language.TYPESCRIPT : Language.JAVASCRIPT;
return config.set(KEY, language);
}
}
exports.parseLanguage = parseLanguage;
//# sourceMappingURL=parse-language.js.map

@@ -1,6 +0,8 @@

declare type ParsePropTypes = (options: {
import { WithConfig } from '../../../utils/config';
interface Params extends WithConfig {
propTypes: boolean;
target?: string;
}) => Promise<boolean>;
}
declare type ParsePropTypes = (options: Params) => Promise<boolean>;
export declare const parsePropTypes: ParsePropTypes;
export {};

@@ -8,9 +8,14 @@ "use strict";

const get_package_json_1 = __importDefault(require("../../../utils/get-package-json"));
exports.parsePropTypes = async ({ propTypes, target = process.cwd() }) => {
const keys_1 = require("./keys");
const KEY = keys_1.PARSE_KEYS.PROP_TYPES;
exports.parsePropTypes = async ({ propTypes, config, target = process.cwd(), ignoreCache, }) => {
if (propTypes)
return propTypes;
const packageJson = await get_package_json_1.default({ cwd: target }) || {};
return config.set(KEY, propTypes);
else if (!ignoreCache && config.has(KEY))
return config.get(KEY);
const packageJson = (await get_package_json_1.default({ cwd: target })) || {};
const { dependencies } = packageJson;
return Boolean(dependencies === null || dependencies === void 0 ? void 0 : dependencies['prop-types']);
propTypes = Boolean(dependencies === null || dependencies === void 0 ? void 0 : dependencies['prop-types']);
return config.set(KEY, propTypes);
};
//# sourceMappingURL=parse-prop-types.js.map

@@ -0,1 +1,2 @@

import { WithConfig } from '../../../utils/config';
export declare enum Styles {

@@ -7,2 +8,6 @@ SCSS = "scss",

export declare const STYLE_MESSAGE: string;
export declare function parseStyle(style: Styles): Promise<Styles>;
interface Params extends WithConfig {
style: Styles;
}
export declare function parseStyle({ style, config, ignoreCache }: Params): Promise<Styles>;
export {};

@@ -5,2 +5,4 @@ "use strict";

const prompt_list_1 = require("../../../utils/prompt-list");
const lodash_1 = require("lodash");
const keys_1 = require("./keys");
var Styles;

@@ -12,18 +14,17 @@ (function (Styles) {

})(Styles = exports.Styles || (exports.Styles = {}));
exports.STYLE_MESSAGE = `Select the type of style you want: (${Object.values(Styles).join(",")})`;
let _lastStyle;
async function parseStyle(style) {
if (typeof style === "string" &&
Object.values(Styles).includes(style)) {
_lastStyle = style;
exports.STYLE_MESSAGE = `Select the type of style you want: (${Object.values(Styles).join(',')})`;
const KEY = keys_1.PARSE_KEYS.STYLE;
async function parseStyle({ style, config, ignoreCache }) {
if (lodash_1.isString(style) && Object.values(Styles).includes(style)) {
return config.set(KEY, style);
}
else if (_lastStyle) {
return _lastStyle;
else if (!ignoreCache && config.has(KEY)) {
return config.get(KEY);
}
else {
_lastStyle = await prompt_list_1.promptList("style", exports.STYLE_MESSAGE, Object.values(Styles).map((value) => ({ value })), false);
style = (await prompt_list_1.promptList('style', exports.STYLE_MESSAGE, Object.values(Styles).map((value) => ({ value })), false));
return config.set(KEY, style);
}
return _lastStyle;
}
exports.parseStyle = parseStyle;
//# sourceMappingURL=parse-style.js.map

@@ -0,1 +1,2 @@

import { WithConfig } from '../../../utils/config';
export declare enum Types {

@@ -5,3 +6,7 @@ FUNCTION = "function",

}
interface Params extends WithConfig {
type: Types;
}
export declare const TYPE_MESSAGE: string;
export declare const parseTypes: (type: Types) => Promise<Types>;
export declare const parseTypes: ({ type, config, ignoreCache }: Params) => Promise<Types>;
export {};

@@ -5,2 +5,4 @@ "use strict";

const prompt_list_1 = require("../../../utils/prompt-list");
const lodash_1 = require("lodash");
const keys_1 = require("./keys");
var Types;

@@ -11,12 +13,16 @@ (function (Types) {

})(Types = exports.Types || (exports.Types = {}));
const KEY = keys_1.PARSE_KEYS.TYPE;
exports.TYPE_MESSAGE = `What type of the component it should be. (${Types.FUNCTION} or ${Types.CLASS})`;
exports.parseTypes = async (type) => {
if (typeof type === "string" &&
Object.values(Types).includes(type)) {
return type;
exports.parseTypes = async ({ type, config, ignoreCache }) => {
if (lodash_1.isString(type) && Object.values(Types).includes(type)) {
return config.set(KEY, type);
}
else if (!ignoreCache && config.has(KEY)) {
return config.get(KEY);
}
else {
return await prompt_list_1.promptList("type", exports.TYPE_MESSAGE, Object.values(Types).map((value) => ({ value })));
type = (await prompt_list_1.promptList(KEY, exports.TYPE_MESSAGE, Object.values(Types).map((value) => ({ value }))));
return config.set(KEY, type);
}
};
//# sourceMappingURL=parse-type.js.map

@@ -10,7 +10,7 @@ "use strict";

exports.checkForMainDependencies = async ({ target = process.cwd() } = {}) => {
const { dependencies } = await get_package_json_1.default({ cwd: target, depth: 9999 }) || {};
const { dependencies } = (await get_package_json_1.default({ cwd: target })) || {};
const hasReact = Boolean(dependencies === null || dependencies === void 0 ? void 0 : dependencies['react']);
if (!hasReact) {
throw new Error(`
Missing ${chalk_1.default.bold("React")} dependence.
Missing ${chalk_1.default.bold('React')} dependence.
This CLI is made for react project 😎 ⚛

@@ -17,0 +17,0 @@ `);

@@ -1,8 +0,4 @@

export declare type PackageJsonType = Record<string, IPackageJson | string | number | boolean>;
interface IPackageJson extends PackageJsonType {
}
export default function getPackageJson({ cwd, depth }?: {
import find from 'find-package-json';
export default function getPackageJson({ cwd }?: {
cwd?: string;
depth?: number;
}): Promise<PackageJsonType | null>;
export {};
}): Promise<find.Package>;

@@ -6,32 +6,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = require("path");
const util_1 = require("util");
const readdir = util_1.promisify(fs_1.default.readdir);
const readFile = util_1.promisify(fs_1.default.readFile);
const exists = util_1.promisify(fs_1.default.exists);
;
async function getPackageJson({ cwd = process.cwd(), depth = 10 } = {}) {
const directories = cwd.split(path_1.sep);
const PACKAGE_JSON = `package.json`;
let iterations = 0;
while (directories.length && iterations < depth) {
iterations++;
const directory = directories.pop();
const path = path_1.join(...directories, directory);
if (!(await exists(path)))
continue;
const dirFiles = await readdir(path);
if (dirFiles.includes(PACKAGE_JSON)) {
const packageJsonRaw = await readFile(path_1.join(path, PACKAGE_JSON), { encoding: 'utf8' });
const packageJson = JSON.parse(packageJsonRaw);
if (!packageJson) {
continue;
}
return packageJson;
}
}
return null;
const find_package_json_1 = __importDefault(require("find-package-json"));
async function getPackageJson({ cwd = process.cwd() } = {}) {
return find_package_json_1.default(cwd).next().value;
}
exports.default = getPackageJson;
//# sourceMappingURL=get-package-json.js.map

@@ -12,3 +12,3 @@ "use strict";

const exists = util_1.promisify(fs_1.default.exists);
const isFile = async (path) => await exists(path) && (await lstat(path)).isFile();
const isFile = async (path) => (await exists(path)) && (await lstat(path)).isFile();
const isInsideTypescript = async (target) => {

@@ -22,3 +22,3 @@ const directories = target.split(path_1.sep);

const tsconfigExists = await isFile(tsconfigPath);
const { devDependencies, dependencies } = await get_package_json_1.default({ cwd: currentPath, depth: 1 }) || {};
const { devDependencies, dependencies } = (await get_package_json_1.default({ cwd: currentPath })) || {};
const haveTsInDependencies = (devDependencies === null || devDependencies === void 0 ? void 0 : devDependencies['typescript']) || (dependencies === null || dependencies === void 0 ? void 0 : dependencies['typescript']);

@@ -25,0 +25,0 @@ if (tsconfigExists && haveTsInDependencies) {

{
"name": "react-creates",
"version": "1.0.14",
"version": "1.0.15",
"description": "React creates for you useful and common tools that adapt themselves to your project for faster and easier development",

@@ -23,4 +23,4 @@ "files": [

"pretest": "npm run build",
"test": "jest",
"create:cmp": "npm run clean && react-creates component __temp__ -f --scss -d __temp__",
"test": "npm link && jest",
"create:cmp": "npm run clean && react-creates component __temp__ -f --scss -d __temp__ --skip-cache",
"deploy:patch": "node deploy -p",

@@ -52,2 +52,4 @@ "deploy:minor": "node deploy -m",

"commander": "^5.1.0",
"configstore": "^5.0.1",
"find-package-json": "^1.2.0",
"inquirer": "^7.3.2",

@@ -64,2 +66,4 @@ "listr": "^0.14.3",

"@types/commander": "^2.12.2",
"@types/configstore": "^4.0.0",
"@types/find-package-json": "^1.1.1",
"@types/inquirer": "^6.5.0",

@@ -83,3 +87,4 @@ "@types/jest": "26.0.0",

"ts-jest": "^26.1.2",
"typescript": "^3.9.6"
"typescript": "^3.9.6",
"utility-types": "^3.10.0"
},

@@ -91,2 +96,2 @@ "husky": {

}
}
}

@@ -17,5 +17,6 @@ <p align="center">

- [Getting Started ⬇️](#getting-started-⬇️)
- [Getting Started ⬇️](#getting-started-)
- [Feeling Lazy](#feeling-lazy)
- [Features](#features)
- [Default values](#default-values)
- [Component](#component)

@@ -61,2 +62,19 @@ - [Start](#start)

## Default values
If you want to make sure all component will have the same features (styling, type, etc..), you can specify it in your `package.json`
For example:
```json
{
"name": "my-project",
"version": "0.1.0",
...
"react-creates": {
"style": "scss"
},
...
}
```
## Component

@@ -74,15 +92,17 @@

| Option | Default | Description |
| --------------------------- | ----------------------------------------------- | ---------------------------------------------------------------- |
| `--scss` | `false` | Force `scss` style |
| `--css` | `false` | Force `css` style |
| `--sass` | `false` | Force `sass` style |
| `-l --language <scripting>` | Calculated (Checks for `tsconfig` to determent) | Select the language you want the component to be |
| `-d --directory <target>` | `process.cwd()` | Component directory |
| `-t --type <component>` | `function` | What type of the component it should be. (function or class) |
| `-pt --prop-types` | `false` | Should add Prop-types. Only works if inside `javascript` project |
| `-f --function` | `false` | Force `function` component |
| `-c --class` | `false` | Force `class` component |
| `-s --style <styling>` | `css` | Selected style |
| `--skip-test` | `false` | Will not create test file |
| Option | Default | Type | Description |
| --------------------------- | ----------------------------------------------- | ---------------------------- | ---------------------------------------------------------------- |
| `--scss` | `false` | boolean | Force `scss` style |
| `--css` | `false` | boolean | Force `css` style |
| `--sass` | `false` | boolean | Force `sass` style |
| `-l --language <scripting>` | Calculated (Checks for `tsconfig` to determent) | `typescript` or `javascript` | Select the language you want the component to be |
| `-d --directory <target>` | `process.cwd()` | string | Component directory |
| `-t --type <component>` | | `function` or `class` | What type of the component it should be. |
| `-pt --prop-types` | `false` | boolean | Should add Prop-types. Only works if inside `javascript` project |
| `-f --function` | `false` | boolean | Force `function` component |
| `-c --class` | `false` | boolean | Force `class` component |
| `-s --style <styling>` | | `css`, `scss`, `sass` | Selected style |
| `--skip-test` | `false` | boolean | Will not create test file |
| `--skip-cache` | `false` | boolean | Won't save cache values |
| `--ignore-cache` | `false` | boolean | Won't use cache values |

@@ -89,0 +109,0 @@ ### Examples

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc