Skip to content

Commit 69c3685

Browse files
committed
feat: add option to prevent install dependencies
resolve #43
1 parent 5f3a339 commit 69c3685

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

bin/mili

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ program
1313
.usage('[options] <repository>')
1414
.description('initialize the project')
1515
.option('-n --app-name [app_name]', `Set your app name.`)
16+
.option('--no-deps', 'Need not install dependencies', false)
1617
.option('--force')
1718
.option('-v --version [version]', 'Set the template version')
1819
.action((repository, option) => {
1920
if (!repository) program.help()
2021

21-
const { appName, force = false } = option
22+
const { appName, force = false, deps = true } = option
2223

2324
let version
2425
if (typeof option.version === 'string') version = option.version
2526

2627
// return init(appName, repository, force, version)
27-
return mili.init({ name: appName, force, repository, version })
28+
return mili.init({ name: appName, force, repository, version, noDeps: !deps })
2829
.then(() => log.info('initialize complete'))
2930
.catch(err => log.error('program', 'initialize break', err))
3031
})
@@ -33,10 +34,11 @@ program
3334
.command('upgrade')
3435
.description('upgrade the template')
3536
.option('--force')
37+
.option('--no-deps', 'Need not install dependencies', false)
3638
.action((option) => {
37-
const { force = false } = option
39+
const { force = false, deps = true } = option
3840

39-
mili.upgrade({ force })
41+
mili.upgrade({ force, noDeps: !deps })
4042
.then(() => log.info('upgrade complete'))
4143
.catch(err => log.error('program', 'upgrade break', err))
4244
})
@@ -46,13 +48,14 @@ program
4648
.description('Update the project with the current version of the template')
4749
.option('--force')
4850
.option('-v --version [version]', 'Set the template version')
51+
.option('--no-deps', 'Need not install dependencies', false)
4952
.action((option) => {
50-
const { force = false } = option
53+
const { force = false, deps = true } = option
5154

5255
let version
5356
if (typeof option.version === 'string') version = option.version
5457

55-
mili.update({ force, version })
58+
mili.update({ force, version, noDeps: !deps })
5659
.then(() => log.info('update complete'))
5760
.catch(err => log.error('program', 'update break', err))
5861
})

src/commands/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = async (options = {}) => {
1313
const cwd = options.cwd || process.cwd()
1414
const name = options.name || basename(cwd)
1515
const repository = options.repository
16+
const noDeps = options.noDeps
1617
let version = options.version
1718

1819
if (!options.force) await securityCheck(process.cwd())
@@ -39,7 +40,7 @@ module.exports = async (options = {}) => {
3940
}
4041

4142

42-
await downloadTemplate(config.template.repository, version)
43+
await downloadTemplate(config.template.repository, version, noDeps)
4344

4445
config = await config.reload({
4546
templateVersion: version,

src/commands/update.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = async (options) => {
1515
cwd = process.cwd(),
1616
// whether to skip the security check
1717
force = false,
18+
noDeps = false,
1819
} = options
1920

2021
// template version expected
@@ -79,7 +80,7 @@ module.exports = async (options) => {
7980
}
8081

8182

82-
await downloadTemplate(config.template.repository, version)
83+
await downloadTemplate(config.template.repository, version, noDeps)
8384
config = await config.reload({
8485
templateVersion: version,
8586
loadTemplate: true,

src/commands/upgrade.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = async (options = {}) => {
1414
cwd = process.cwd(),
1515
// whether to skip the security check
1616
force = false,
17+
noDeps = false,
1718
} = options
1819

1920
if (!force) await securityCheck(process.cwd())
@@ -29,7 +30,7 @@ module.exports = async (options = {}) => {
2930
}
3031
}
3132
const version = versions[0]
32-
await downloadTemplate(config.template.repository, version)
33+
await downloadTemplate(config.template.repository, version, noDeps)
3334
config = await config.reload({
3435
templateVersion: version,
3536
loadTemplate: true,

src/download-template/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const clone = require('./clone')
77
const npmInstall = require('./npm-install')
88

99

10-
module.exports = async (repository, version) => {
10+
module.exports = async (repository, version, noDeps) => {
1111
const localStoragePath = getLocalStoragePath(repository, version)
1212

1313
if (repository.type === 'local') await copy(repository, version, localStoragePath)
@@ -20,5 +20,5 @@ module.exports = async (repository, version) => {
2020
].join('\n'))
2121
}
2222

23-
await installDeps(localStoragePath)
23+
if (!noDeps) await installDeps(localStoragePath)
2424
}

0 commit comments

Comments
 (0)