@multiplatform.one/cli
Advanced tools
Comparing version 1.0.28 to 1.0.30
{ | ||
"name": "@multiplatform.one/cli", | ||
"version": "1.0.28", | ||
"version": "1.0.30", | ||
"author": "BitSpur <support@bitspur.com> (https://bitspur.com)", | ||
@@ -51,10 +51,12 @@ "contributors": [ | ||
"devDependencies": { | ||
"@types/inquirer": "^9.0.7", | ||
"@types/node": "~20.12.13", | ||
"tsup": "^8.1.0", | ||
"typescript": "~5.3.3", | ||
"@multiplatform.one/utils": "^0.0.13" | ||
"@multiplatform.one/utils": "^0.0.15" | ||
}, | ||
"dependencies": { | ||
"commander": "^9.5.0", | ||
"execa": "^9.2.0" | ||
"execa": "^9.2.0", | ||
"inquirer": "^9.2.23" | ||
}, | ||
@@ -61,0 +63,0 @@ "transpileModules": [ |
@@ -22,3 +22,8 @@ /* | ||
import fs from 'fs/promises'; | ||
import inquirer from 'inquirer'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import pkg from '@multiplatform.one/cli/package.json'; | ||
import type { CookieCutterConfig } from '../types'; | ||
import { execa } from 'execa'; | ||
@@ -28,3 +33,5 @@ import { fileURLToPath } from 'url'; | ||
process.env.COOKIECUTTER = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/cookiecutter.sh'); | ||
program.name('multiplatform.one'); | ||
program.version(pkg.version); | ||
@@ -34,7 +41,36 @@ program | ||
.argument('[remote]', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter') | ||
.option('--name <name>', 'the name of the project') | ||
.description('init multiplatform.one') | ||
.action(async (remote) => { | ||
await execa('sh', [path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/init.sh'), remote], { | ||
stdio: 'inherit', | ||
}); | ||
if ((await execa('git', ['rev-parse', '--is-inside-work-tree'])).stdout.trim() === 'true') { | ||
throw new Error('multiplatform.one cannot be initialized inside a git repository'); | ||
} | ||
const cookieCutterConfig: CookieCutterConfig = { | ||
name: | ||
program.opts().name || | ||
( | ||
await inquirer.prompt([ | ||
{ | ||
message: 'What is the project name?', | ||
name: 'name', | ||
type: 'input', | ||
}, | ||
]) | ||
)?.name, | ||
}; | ||
const cookieCutterConfigFile = await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-')); | ||
await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2)); | ||
await execa( | ||
'sh', | ||
[ | ||
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/init.sh'), | ||
'-f', | ||
'--config-file', | ||
cookieCutterConfigFile, | ||
remote, | ||
], | ||
{ | ||
stdio: 'inherit', | ||
}, | ||
); | ||
}); | ||
@@ -47,7 +83,39 @@ | ||
.action(async (remote) => { | ||
await execa('sh', [path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/update.sh'), remote], { | ||
stdio: 'inherit', | ||
}); | ||
if ((await execa('git', ['rev-parse', '--is-inside-work-tree'])).stdout.trim() !== 'true') { | ||
throw new Error('multiplatform.one cannot be updated outside of a git repository'); | ||
} | ||
if ((await execa('git', ['diff', '--cached', '--quiet'])).stdout.trim() !== 'true') { | ||
throw new Error('multiplatform.one cannot be updated with uncommitted changes'); | ||
} | ||
const projectRoot = (await execa('git', ['rev-parse', '--show-toplevel'])).stdout.trim(); | ||
let cookieCutterConfig: CookieCutterConfig | undefined; | ||
if ( | ||
(await fs.stat(path.resolve(projectRoot, 'package.json'))).isFile() && | ||
(await fs.stat(path.resolve(projectRoot, 'app/package.json'))).isFile() && | ||
JSON.parse(await fs.readFile(path.resolve(projectRoot, 'app/package.json'), 'utf8'))?.dependencies?.[ | ||
'multiplatform.one' | ||
]?.length | ||
) { | ||
const name = JSON.parse(await fs.readFile(path.resolve(projectRoot, 'package.json'), 'utf8'))?.name; | ||
if (name) cookieCutterConfig = { name }; | ||
} | ||
if (!cookieCutterConfig) throw new Error('not a multiplatform.one project'); | ||
const cookieCutterConfigFile = await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-')); | ||
await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2)); | ||
await execa( | ||
'sh', | ||
[ | ||
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/update.sh'), | ||
'-f', | ||
'--config-file', | ||
cookieCutterConfigFile, | ||
remote, | ||
], | ||
{ | ||
stdio: 'inherit', | ||
cwd: projectRoot, | ||
}, | ||
); | ||
}); | ||
program.parse(process.argv); |
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
24428
15
259
3
5
2
+ Addedinquirer@^9.2.23
+ Added@inquirer/figures@1.0.8(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-spinners@2.9.2(transitive)
+ Addedcli-width@4.1.0(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinquirer@9.3.7(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-interactive@1.0.0(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedmute-stream@1.0.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedora@5.4.1(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedrun-async@3.0.0(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwcwidth@1.0.1(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedyoctocolors-cjs@2.1.2(transitive)