This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
168 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
/* eslint-disable no-unused-vars */ | ||
module.exports = (api, config) => {}; | ||
/* eslint-disable no-unused-vars,no-case-declarations */ | ||
const path = require('path'); | ||
const { info, chalk, warn } = require('@vue/cli-shared-utils'); | ||
const fs = require('fs'); | ||
const multipleBuild = require('./src/command/multiple-build'); | ||
|
||
module.exports = (api, config) => { | ||
api.registerCommand( | ||
'vue', | ||
{ | ||
usage: '<build|check> <pattern> [options]', | ||
description: 'Build multiple vue app', | ||
options: { | ||
'-e, --execute <cmd>': { | ||
type: String, | ||
description: 'Run command to build a vue application' | ||
} | ||
} | ||
}, | ||
async (commander, args) => { | ||
const [mode = 'build', pattern = path.join(config.projectDir, '**')] = args; | ||
|
||
switch (mode) { | ||
case 'build': | ||
info(`Starting build vue app...`); | ||
|
||
await multipleBuild(config, { | ||
cmd: commander.execute || 'vue-cli-service build --mode production', | ||
pattern | ||
}); | ||
break; | ||
|
||
case 'check': | ||
const { entries } = config.vueCli; | ||
|
||
info(`Check entries for currentWebsite ${chalk.cyan(config.currentWebsite)}`); | ||
|
||
entries.forEach(entry => { | ||
entry.paths.forEach(file => { | ||
if (!fs.existsSync(file)) { | ||
warn(`Entry is KO: ${chalk.red(file)}`); | ||
process.exit(-1); | ||
} | ||
}); | ||
}); | ||
|
||
info(`Entries is ok for the currentWebsite ${chalk.cyan(config.currentWebsite)}`); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const path = require('path'); | ||
const gulp = require('gulp'); | ||
const tap = require('gulp-tap'); | ||
const { info, chalk } = require('@vue/cli-shared-utils'); | ||
const execa = require('execa'); | ||
|
||
module.exports = (config, options) => | ||
gulp.src(options.pattern).pipe( | ||
tap(projectFolder => { | ||
const currentWebsite = path.basename(projectFolder.path); | ||
|
||
try { | ||
execa.sync('nsc', ['vue', 'check', '--currentWebsite', currentWebsite], { | ||
shell: true, | ||
env: { | ||
FORCE_COLOR: true | ||
}, | ||
stdio: 'inherit' | ||
}); | ||
} catch (er) { | ||
return; | ||
} | ||
|
||
info(`Start build Project ${chalk.cyan(currentWebsite)}`); | ||
|
||
let cmd = `${options.cmd}${options.cmd.match(/^npm/) ? ' -- ' : ''} --currentWebsite ${currentWebsite}`; | ||
cmd = cmd.split(' '); | ||
|
||
const task = cmd[0]; | ||
const args = cmd.splice(1).filter(t => !!t); | ||
|
||
execa.sync(task, args, { | ||
shell: true, | ||
env: { | ||
FORCE_COLOR: true | ||
}, | ||
stdio: 'inherit' | ||
}); | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.