@stormid/scaffold-cli
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -1,2 +0,2 @@ | ||
const { info, warn, error, isDir, install, initGit } = require('../utils'); | ||
const { info, warn, error, isDir, install, initGit, npmCheck } = require('../utils'); | ||
const { resolve } = require('path'); | ||
@@ -9,2 +9,3 @@ const figlet = require('figlet'); | ||
const REPO = 'stormid/scaffold'; | ||
const UMBRACO_LIBRARY = '@stormid/umbraco-library'; | ||
@@ -45,2 +46,13 @@ module.exports = async function(dest, argv) { | ||
}); | ||
if (argv['umbraco']) { | ||
if (argv['umbraco'] === true) info(`-> Adding Umbraco Library`); | ||
else { | ||
const packageExists = await npmCheck('@stormid/umbraco-library', argv['umbraco']); | ||
if (packageExists) info(`-> Adding Umbraco Library version ${argv['umbraco']}`); | ||
else { | ||
return error(`-> Cannot find Umbraco Library version '${argv['umbraco']}'`); | ||
} | ||
} | ||
} | ||
@@ -65,2 +77,3 @@ info('-> Creating project'); | ||
pkgData.version = "0.1.0"; | ||
if (argv['umbraco']) pkgData.dependencies = Object.assign({}, pkgData.dependencies, { UMBRACO_LIBRARY: argv['umbraco'] === true ? "latest" : argv['umbraco'] }); | ||
await fs.writeFile(pkgFile, JSON.stringify(pkgData, null, 2)); | ||
@@ -75,2 +88,10 @@ } else { | ||
} | ||
if (argv['umbraco']) { | ||
try { | ||
fs.copySync(`${target}/node_modules/${UMBRACO_LIBRARY}/src/css/import-template/index.scss`, `${target}/src/css/index.scss`); | ||
} catch(err){ | ||
warn(err); | ||
} | ||
} | ||
@@ -77,0 +98,0 @@ // await initGit(target); |
@@ -30,3 +30,4 @@ #!/usr/bin/env node | ||
.option('-v, --verbose', 'Verbose output') | ||
.option('--umbraco', 'Include the Umbraco library') | ||
.action(require('./commands')) | ||
.parse(process.argv); |
@@ -5,2 +5,5 @@ const { blue, yellow, red } = require('kleur'); | ||
const spawn = require('cross-spawn-promise'); | ||
const npmName = require('npm-name'); | ||
const fetch = require('node-fetch'); | ||
const hasCommand = function(str) { | ||
@@ -77,2 +80,18 @@ return !!which.sync(str, { nothrow: true }); | ||
} | ||
}; | ||
}; | ||
exports.npmCheck = (module, version) => | ||
new Promise((resolve, reject) => { | ||
return npmName(module) | ||
.then(isNoValid => { | ||
if (isNoValid) | ||
throw new Error(`Error > Cannot find ${module} in the NPM registry`) | ||
fetch(`http://registry.npmjs.org/${module}`) | ||
.then(res => res.json()) | ||
.then(body => { | ||
return resolve({}.hasOwnProperty.call(body.time, version)) | ||
}) | ||
}) | ||
.catch(err => reject(err.message)) | ||
}) |
{ | ||
"name": "@stormid/scaffold-cli", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Start a new project using the StormId scaffold", | ||
@@ -26,5 +26,2 @@ "author": "stormid", | ||
], | ||
"devDependencies": { | ||
"jest": "^24.8.0" | ||
}, | ||
"dependencies": { | ||
@@ -37,2 +34,4 @@ "cli-table": "^0.3.1", | ||
"kleur": "^3.0.3", | ||
"node-fetch": "^2.6.7", | ||
"npm-name": "^6.0.1", | ||
"ora": "^3.4.0", | ||
@@ -39,0 +38,0 @@ "sade": "^1.6.1", |
@@ -19,5 +19,6 @@ # Scaffold CLI | ||
--name The application name. | ||
--cwd A directory to use instead of $PWD. | ||
--install Installs dependencies. [boolean] [default: true] | ||
--name The application name. | ||
--umbraco <version> Install the @stormid/umbraco-library [npm version] [default: latest] | ||
--cwd A directory to use instead of $PWD. | ||
--install Installs dependencies. [boolean] [default: true] | ||
``` |
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
Network access
Supply chain riskThis module accesses the network.
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
8756
0
204
24
12
1
+ Addednode-fetch@^2.6.7
+ Addednpm-name@^6.0.1
+ Added@sindresorhus/is@2.1.1(transitive)
+ Added@szmarczak/http-timer@4.0.6(transitive)
+ Added@types/cacheable-request@6.0.3(transitive)
+ Added@types/http-cache-semantics@4.0.4(transitive)
+ Added@types/keyv@3.1.4(transitive)
+ Added@types/node@22.7.4(transitive)
+ Added@types/responselike@1.0.3(transitive)
+ Addedaggregate-error@3.1.0(transitive)
+ Addedcacheable-lookup@2.0.1(transitive)
+ Addedcacheable-request@7.0.4(transitive)
+ Addedclean-stack@2.2.0(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addeddecompress-response@5.0.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddefer-to-connect@2.0.1(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedgot@10.7.0(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-scoped@2.1.0(transitive)
+ Addedis-url-superb@4.0.0(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlodash.zip@4.2.0(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addedmimic-response@1.0.12.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednormalize-url@6.1.0(transitive)
+ Addednpm-name@6.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedorg-regex@1.0.0(transitive)
+ Addedp-cancelable@2.1.1(transitive)
+ Addedp-event@4.2.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-map@3.0.0(transitive)
+ Addedp-timeout@3.2.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedregistry-auth-token@4.2.2(transitive)
+ Addedregistry-url@5.1.0(transitive)
+ Addedresponselike@2.0.1(transitive)
+ Addedscoped-regex@2.1.0(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedto-readable-stream@2.1.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtype-fest@0.10.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)