mythix 2.8.3 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/application.js +7 -3
- package/src/cli/cli-utils.js +4 -1
- package/src/cli/deploy-command.js +32 -23
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -235,14 +235,18 @@ class Application extends EventEmitter {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
loadConfig(configPath) {
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
let appOptions = this.getOptions();
|
|
239
|
+
let environment = (appOptions.environment || process.NODE_ENV || 'development');
|
|
240
|
+
|
|
241
|
+
if (!configPath)
|
|
242
|
+
return wrapConfig(Object.assign({}, { environment }));
|
|
240
243
|
|
|
244
|
+
try {
|
|
241
245
|
let config = require(configPath);
|
|
242
246
|
if (config.__esModule)
|
|
243
247
|
config = config['default'];
|
|
244
248
|
|
|
245
|
-
return wrapConfig(Object.assign({}, config || {}, { environment
|
|
249
|
+
return wrapConfig(Object.assign({}, config || {}, { environment }));
|
|
246
250
|
} catch (error) {
|
|
247
251
|
this.getLogger().error(`Error while trying to load application configuration ${configPath}: `, error);
|
|
248
252
|
throw error;
|
package/src/cli/cli-utils.js
CHANGED
|
@@ -324,6 +324,9 @@ function loadCommand(name) {
|
|
|
324
324
|
|
|
325
325
|
function getCommandFiles(commandsPath, filterFunc) {
|
|
326
326
|
try {
|
|
327
|
+
if (!commandsPath)
|
|
328
|
+
return [];
|
|
329
|
+
|
|
327
330
|
return walkDir(commandsPath, {
|
|
328
331
|
filter: (fullFileName, fileName, stats) => {
|
|
329
332
|
if (typeof filterFunc === 'function')
|
|
@@ -390,7 +393,7 @@ function resolveConfig(config) {
|
|
|
390
393
|
|
|
391
394
|
function loadMythixConfig(_mythixConfigPath, _appRootPath) {
|
|
392
395
|
let mythixConfigPath = _mythixConfigPath;
|
|
393
|
-
let configPath
|
|
396
|
+
let configPath = mythixConfigPath;
|
|
394
397
|
|
|
395
398
|
try {
|
|
396
399
|
let stats = FileSystem.statSync(mythixConfigPath);
|
|
@@ -288,6 +288,10 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
async postCloneProject() {
|
|
292
|
+
|
|
293
|
+
}
|
|
294
|
+
|
|
291
295
|
async copyFile(dryRun, sourceFilePath, targetFilePath) {
|
|
292
296
|
let targetDir = Path.dirname(targetFilePath);
|
|
293
297
|
if (!FileSystem.existsSync(targetDir))
|
|
@@ -361,6 +365,7 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
361
365
|
|
|
362
366
|
async archiveProject(deployConfig) {
|
|
363
367
|
let {
|
|
368
|
+
dryRun,
|
|
364
369
|
tempLocation,
|
|
365
370
|
version,
|
|
366
371
|
} = deployConfig;
|
|
@@ -368,7 +373,7 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
368
373
|
let archiveLocation = deployConfig.archiveLocation = Path.join(tempLocation, `${version}.tar.gz`);
|
|
369
374
|
|
|
370
375
|
await this.spawnCommand(
|
|
371
|
-
|
|
376
|
+
dryRun,
|
|
372
377
|
'tar',
|
|
373
378
|
[
|
|
374
379
|
'-czf',
|
|
@@ -653,26 +658,28 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
653
658
|
relativeConfigPath,
|
|
654
659
|
} = deployConfig;
|
|
655
660
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
661
|
+
if (relativeConfigPath) {
|
|
662
|
+
let deployLocation = this.joinUnixPath(decodeURIComponent(target.pathname), '' + deployConfig.version);
|
|
663
|
+
let targetConfigPath = this.joinUnixPath(decodeURIComponent(target.pathname), 'shared', 'config');
|
|
664
|
+
let sourceConfigPath = this.joinUnixPath(deployLocation, relativeConfigPath);
|
|
665
|
+
let nodeModulesLink = this.joinUnixPath(targetConfigPath, 'node_modules');
|
|
660
666
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
667
|
+
// Ensure shared/config exists
|
|
668
|
+
await this.executeRemoteCommands(target, deployConfig, [
|
|
669
|
+
{ command: 'test', args: [ '!', '-d', `"${targetConfigPath}"`, '&&', `${this.sudo(deployConfig)}cp -a "${sourceConfigPath}" "${targetConfigPath}"`, '|| true' ] },
|
|
670
|
+
]);
|
|
665
671
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
672
|
+
// Ensure shared/config/node_modules symlink exists
|
|
673
|
+
await this.executeRemoteCommands(target, deployConfig, [
|
|
674
|
+
{ command: 'test', args: [ '!', '-e', `"${nodeModulesLink}"`, '&&', `{ cd "${targetConfigPath}"; ${this.sudo(deployConfig)}ln -s "../../current/node_modules" "node_modules"; }`, '|| true' ] },
|
|
675
|
+
]);
|
|
670
676
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
677
|
+
// Remove app/config and symlink to ../shared/app/config
|
|
678
|
+
await this.executeRemoteCommands(target, deployConfig, [
|
|
679
|
+
{ command: 'rm', args: [ '-fr', `"${sourceConfigPath}"` ] },
|
|
680
|
+
{ command: 'ln', args: [ '-s', `"${targetConfigPath}"`, `"${sourceConfigPath}"` ] },
|
|
681
|
+
]);
|
|
682
|
+
}
|
|
676
683
|
|
|
677
684
|
await this.installModulesForApp(target, deployConfig);
|
|
678
685
|
}
|
|
@@ -692,7 +699,7 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
692
699
|
{ command: 'ls', args: [ '-1', `"${deployLocation}"`, '|', 'grep', '-P', '"\\d+"' ] },
|
|
693
700
|
]);
|
|
694
701
|
|
|
695
|
-
let versions = result.stdout.split(/\n+/g).map((part) => part.trim()).filter(Boolean).sort();
|
|
702
|
+
let versions = (result.stdout || '').split(/\n+/g).map((part) => part.trim()).filter(Boolean).sort();
|
|
696
703
|
let versionsToRemove = versions.slice(0, -LATEST_DEPLOY_VERSIONS_TO_KEEP);
|
|
697
704
|
|
|
698
705
|
if (Nife.isNotEmpty(versionsToRemove)) {
|
|
@@ -809,7 +816,8 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
809
816
|
if (!deployConfig.rootPath)
|
|
810
817
|
deployConfig.rootPath = Path.dirname(configPath);
|
|
811
818
|
|
|
812
|
-
|
|
819
|
+
if (appOptions.configPath)
|
|
820
|
+
deployConfig.relativeConfigPath = appOptions.configPath.substring(deployConfig.rootPath.length).replace(/^[/\\.]+/, '').replace(/[/\\]+$/, '');
|
|
813
821
|
|
|
814
822
|
let git = deployConfig.git || {};
|
|
815
823
|
if (git.useGitIgnore) {
|
|
@@ -894,7 +902,7 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
894
902
|
|
|
895
903
|
console.log(`-------- Deploy ${deployConfig.version} --------`);
|
|
896
904
|
console.log(` Application name: ${appName}`);
|
|
897
|
-
console.log(` Application config location:
|
|
905
|
+
console.log(` Application config location: ${(deployConfig.relativeConfigPath) ? `./${deployConfig.relativeConfigPath}` : '<none>'}`);
|
|
898
906
|
console.log(` Temporary file location: ${deployConfig.tempLocation}`);
|
|
899
907
|
console.log(` Project file location: ${deployConfig.rootPath}`);
|
|
900
908
|
console.log('');
|
|
@@ -916,8 +924,8 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
916
924
|
console.log(' Command log:');
|
|
917
925
|
|
|
918
926
|
try {
|
|
919
|
-
this.mkdirSync(
|
|
920
|
-
this.mkdirSync(
|
|
927
|
+
this.mkdirSync(false, tempLocation);
|
|
928
|
+
this.mkdirSync(false, Path.join(tempLocation, deployConfig.version));
|
|
921
929
|
|
|
922
930
|
if (Nife.isNotEmpty(branch) && Nife.isEmpty(repository)) {
|
|
923
931
|
repository = await this.getRepositoryURL(remoteName);
|
|
@@ -926,6 +934,7 @@ module.exports = defineCommand('deploy', ({ Parent }) => {
|
|
|
926
934
|
}
|
|
927
935
|
|
|
928
936
|
await this.cloneProject(deployConfig);
|
|
937
|
+
await this.postCloneProject(deployConfig);
|
|
929
938
|
await this.copyProjectFilesToDeployFolder(deployConfig);
|
|
930
939
|
await this.prepProjectPreDeploy(deployConfig);
|
|
931
940
|
await this.archiveProject(deployConfig);
|