react-creates
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -15,2 +15,3 @@ "use strict"; | ||
const options_logger_1 = require("./options-logger"); | ||
const parse_prop_types_1 = require("./parsers/parse-prop-types"); | ||
exports.createComponent = () => commander_1.program | ||
@@ -55,10 +56,11 @@ .command("component <name>") | ||
`); | ||
target = await parse_target_1.parseTarget({ name, target }); | ||
const options = { | ||
name, | ||
target: await parse_target_1.parseTarget({ name, target }), | ||
target, | ||
type: await parse_type_1.parseTypes(type), | ||
language: await parse_language_1.parseLanguage(language), | ||
style: await parse_style_1.parseStyle(style), | ||
propTypes: await parse_prop_types_1.parsePropTypes({ propTypes, target }), | ||
entry: Boolean(entry), | ||
propTypes: Boolean(propTypes), | ||
}; | ||
@@ -65,0 +67,0 @@ options_logger_1.optionsLogger(options); |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (Boolean(value)) | ||
console.log(` ⚛️ ${lodash_1.startCase(name)}: ${chalk_1.default.bold.green(value)}`); | ||
console.log(`⚛️ ${lodash_1.startCase(name)}: ${chalk_1.default.bold.green(value)}`); | ||
} | ||
@@ -15,0 +15,0 @@ console.log(''); |
@@ -11,7 +11,7 @@ "use strict"; | ||
const readdir = util_1.promisify(fs_1.default.readdir); | ||
const _parseTarget = async ({ name, target }) => { | ||
const _parseTarget = async ({ name, target, skipCwd = false }) => { | ||
if (typeof target !== "string") { | ||
throw new Error("Invalid option: directory"); | ||
} | ||
if (!target.includes(process.cwd())) { | ||
if (!skipCwd && !target.includes(process.cwd())) { | ||
target = path_1.join(process.cwd(), target); | ||
@@ -18,0 +18,0 @@ } |
@@ -9,23 +9,20 @@ "use strict"; | ||
const util_1 = require("util"); | ||
const get_package_json_1 = __importDefault(require("./get-package-json")); | ||
const lstat = util_1.promisify(fs_1.default.lstat); | ||
const exists = util_1.promisify(fs_1.default.exists); | ||
const isFile = async (path) => await exists(path) && (await lstat(path)).isFile(); | ||
const isInsideTypescript = async (target) => { | ||
let currentPath = target; | ||
let itr = 0; | ||
let found = false; | ||
const MAX_ITERATIONS = +process.env.MAX_TYPESCRIPT_ITERATIONS || 10; | ||
while (itr < MAX_ITERATIONS && !found) { | ||
if (await exists(currentPath)) { | ||
if (await exists(path_1.join(currentPath, "tsconfig.json"))) { | ||
found = true; | ||
} | ||
else { | ||
const currentPathArray = currentPath.split(path_1.sep); | ||
currentPath = currentPathArray.slice(0, currentPathArray.length - 1).join(path_1.sep); | ||
} | ||
const directories = target.split(path_1.sep); | ||
const TSCONFIG = `tsconfig.json`; | ||
while (directories.length) { | ||
const directory = directories.pop(); | ||
const tsconfigPath = path_1.join(path_1.sep, ...directories, directory, TSCONFIG); | ||
const tsconfigExists = await isFile(tsconfigPath); | ||
const { devDependencies, dependencies } = await get_package_json_1.default({ cwd: target, depth: 1 }) || {}; | ||
const haveTsInDependencies = (devDependencies === null || devDependencies === void 0 ? void 0 : devDependencies['typescript']) || (dependencies === null || dependencies === void 0 ? void 0 : dependencies['typescript']); | ||
if (tsconfigExists && haveTsInDependencies) { | ||
return true; | ||
} | ||
else { | ||
itr = MAX_ITERATIONS; | ||
} | ||
} | ||
return found; | ||
return false; | ||
}; | ||
@@ -32,0 +29,0 @@ async function isTypescript(target = process.cwd()) { |
{ | ||
"name": "react-creates", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Create React Component folder works on macOS, Windows, and Linux.", | ||
@@ -17,4 +17,4 @@ "files": [ | ||
"dev": "tsc -w", | ||
"lint": "eslint --fix --ext .js,.ts .", | ||
"pretest": "npm run build", | ||
"lint": "eslint --ext .js,.ts .", | ||
"pretest": "npm run build && npm link", | ||
"test": "jest", | ||
@@ -24,4 +24,5 @@ "create:cmp": "npm run clean && npx react-creates component __temp__ -f --scss -d __temp__ ", | ||
"deploy:minor": "node deploy -m", | ||
"prepublish": "npm run build && npm run deploy:patch", | ||
"postpublish": "node deploy -g" | ||
"predeploy": "npm run build && npm run deploy:patch", | ||
"deploy": "npm publish", | ||
"postdeplloy": "node deploy -g" | ||
}, | ||
@@ -70,2 +71,3 @@ "keywords": [ | ||
"execa": "^4.0.3", | ||
"husky": "^4.2.5", | ||
"jest": "^26.1.0", | ||
@@ -75,3 +77,8 @@ "tempy": "^0.5.0", | ||
"typescript": "^3.9.6" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-push": "npm test" | ||
} | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
33710
49
501
19
8