@flarum/cli 2.0.0-beta.11 → 2.0.0-beta.14
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/README.md +176 -43
- package/boilerplate/skeleton/extension/.gitattributes +1 -0
- package/boilerplate/skeleton/extension/.github/workflows/backend.yml +1 -1
- package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +3 -1
- package/boilerplate/skeleton/extension/LICENSE.md +1 -1
- package/boilerplate/skeleton/extension/composer.json +4 -2
- package/boilerplate/skeleton/extension/extend.php +2 -2
- package/boilerplate/skeleton/extension/js/package.json +4 -1
- package/boilerplate/skeleton/extension/tests/phpunit.integration.xml +1 -0
- package/lib/base-command.d.ts +3 -1
- package/lib/base-command.js +27 -14
- package/lib/boilersmith/io.d.ts +28 -8
- package/lib/boilersmith/io.js +4 -2
- package/lib/boilersmith/paths.d.ts +2 -2
- package/lib/boilersmith/paths.js +2 -2
- package/lib/boilersmith/scaffolding/audit-step-factory.js +10 -10
- package/lib/boilersmith/scaffolding/infra-step-factory.js +2 -2
- package/lib/boilersmith/scaffolding/init-step-factory.js +5 -5
- package/lib/boilersmith/scaffolding/module.d.ts +19 -8
- package/lib/boilersmith/scaffolding/module.js +30 -17
- package/lib/boilersmith/scaffolding/scaffolder.d.ts +4 -1
- package/lib/boilersmith/scaffolding/scaffolder.js +29 -29
- package/lib/boilersmith/scaffolding/template-param.d.ts +1 -1
- package/lib/boilersmith/scaffolding/template-param.js +2 -2
- package/lib/boilersmith/step-manager.d.ts +0 -1
- package/lib/boilersmith/step-manager.js +10 -20
- package/lib/boilersmith/steps/stub-base.js +1 -1
- package/lib/boilersmith/utils/clone-and-fill.js +1 -1
- package/lib/boilersmith/utils/commit-async.d.ts +2 -0
- package/lib/boilersmith/utils/commit-async.js +15 -0
- package/lib/commands/audit/infra.d.ts +1 -1
- package/lib/commands/audit/infra.js +30 -8
- package/lib/commands/infra.d.ts +2 -2
- package/lib/commands/infra.js +18 -12
- package/lib/commands/init.d.ts +1 -1
- package/lib/commands/init.js +4 -2
- package/lib/commands/make/backend/api-controller.js +1 -2
- package/lib/commands/make/backend/api-serializer-attributes.js +1 -2
- package/lib/commands/make/backend/command.js +1 -2
- package/lib/commands/make/backend/event-listener.js +1 -2
- package/lib/commands/make/backend/handler.js +2 -5
- package/lib/commands/make/backend/integration-test.js +2 -4
- package/lib/commands/make/backend/migration.js +1 -2
- package/lib/commands/make/backend/model.js +1 -2
- package/lib/commands/make/backend/policy.js +1 -2
- package/lib/commands/make/backend/route.js +1 -2
- package/lib/commands/make/backend/service-provider.js +1 -2
- package/lib/commands/make/frontend/model.js +2 -5
- package/lib/commands/monorepo/create.d.ts +15 -0
- package/lib/commands/monorepo/create.js +20 -0
- package/lib/commands/update/js-imports.js +1 -2
- package/lib/help.js +1 -1
- package/lib/steps/gen-ext-scaffolder.d.ts +2 -2
- package/lib/steps/gen-ext-scaffolder.js +144 -46
- package/lib/steps/js/base.js +2 -4
- package/lib/steps/js/model.js +4 -4
- package/lib/steps/misc/git.d.ts +1 -1
- package/lib/steps/misc/git.js +2 -2
- package/lib/steps/misc/npm.d.ts +11 -0
- package/lib/steps/misc/npm.js +19 -0
- package/lib/steps/monorepo/create.d.ts +17 -0
- package/lib/steps/monorepo/create.js +181 -0
- package/lib/steps/stubs/backend/api-controller.d.ts +1 -1
- package/lib/steps/stubs/backend/api-controller.js +3 -0
- package/lib/steps/stubs/backend/api-serializer.d.ts +1 -1
- package/lib/steps/stubs/backend/api-serializer.js +3 -0
- package/lib/steps/stubs/backend/command.d.ts +0 -5
- package/lib/steps/stubs/backend/command.js +1 -0
- package/lib/steps/stubs/backend/event-listener.d.ts +1 -1
- package/lib/steps/stubs/backend/event-listener.js +2 -0
- package/lib/steps/stubs/backend/handler-command.d.ts +1 -1
- package/lib/steps/stubs/backend/handler-command.js +1 -0
- package/lib/steps/stubs/backend/handler.d.ts +1 -1
- package/lib/steps/stubs/backend/handler.js +4 -0
- package/lib/steps/stubs/backend/integration-test.d.ts +1 -1
- package/lib/steps/stubs/backend/integration-test.js +2 -0
- package/lib/steps/stubs/backend/job.d.ts +1 -1
- package/lib/steps/stubs/backend/job.js +1 -0
- package/lib/steps/stubs/backend/migration.js +4 -1
- package/lib/steps/stubs/backend/model.d.ts +1 -1
- package/lib/steps/stubs/backend/model.js +1 -0
- package/lib/steps/stubs/backend/policy.d.ts +1 -1
- package/lib/steps/stubs/backend/policy.js +2 -0
- package/lib/steps/stubs/backend/repository.d.ts +1 -1
- package/lib/steps/stubs/backend/repository.js +2 -0
- package/lib/steps/stubs/backend/service-provider.d.ts +1 -1
- package/lib/steps/stubs/backend/service-provider.js +1 -0
- package/lib/steps/stubs/backend/validator.d.ts +1 -1
- package/lib/steps/stubs/backend/validator.js +1 -0
- package/lib/steps/stubs/flarum-base.js +1 -1
- package/lib/steps/stubs/frontend/component.d.ts +0 -5
- package/lib/steps/stubs/frontend/component.js +1 -0
- package/lib/steps/stubs/frontend/modal.d.ts +0 -5
- package/lib/steps/stubs/frontend/modal.js +1 -0
- package/lib/steps/stubs/frontend/model.d.ts +0 -5
- package/lib/steps/stubs/frontend/model.js +1 -0
- package/lib/steps/stubs/js-base.js +8 -5
- package/lib/steps/stubs/php-base.js +10 -8
- package/lib/steps/update/js-imports.js +8 -2
- package/lib/utils/composer.d.ts +1 -0
- package/lib/utils/migration.js +3 -1
- package/lib/utils/monorepo.d.ts +24 -0
- package/lib/utils/monorepo.js +24 -0
- package/lib/utils/validation.d.ts +2 -0
- package/lib/utils/validation.js +6 -0
- package/oclif.manifest.json +1 -1
- package/package.json +10 -5
- package/php-subsystem/composer.json +9 -9
- package/php-subsystem/composer.lock +64 -71
- package/php-subsystem/vendor/composer/installed.json +54 -61
- package/php-subsystem/vendor/nikic/php-parser/README.md +55 -59
- package/php-subsystem/vendor/nikic/php-parser/composer.json +39 -39
- package/php-subsystem/vendor/nikic/php-parser/grammar/README.md +17 -20
|
@@ -17,28 +17,28 @@ function auditStepFactory(dry, scaffoldDir, modules, templateParams, excludeScaf
|
|
|
17
17
|
async run(_fs, paths, io, _providers) {
|
|
18
18
|
const paramVals = await (0, template_param_1.currParamValues)(templateParams, _fs, paths, io);
|
|
19
19
|
modulesEnabled = await (0, module_1.currModulesEnabled)(modules, _fs, paths, moduleStatusCache);
|
|
20
|
-
const actionableModules = modules.filter(m => m.updatable && modulesEnabled[m.name] && (!m.togglable || !m.dependsOn.some(dep => !modulesEnabled[dep])));
|
|
21
|
-
io.info((0, cond_format_1.condFormat)(io.supportsAnsiColor, m => chalk_1.default.yellow(chalk_1.default.bold(chalk_1.default.underline(m))), `Auditing infrastructure for ${actionableModules.length} enabled modules:`), true);
|
|
20
|
+
const actionableModules = modules.filter((m) => m.updatable && modulesEnabled[m.name] && (!m.togglable || !m.dependsOn.some((dep) => !modulesEnabled[dep])));
|
|
21
|
+
io.info((0, cond_format_1.condFormat)(io.supportsAnsiColor, (m) => chalk_1.default.yellow(chalk_1.default.bold(chalk_1.default.underline(m))), `Auditing infrastructure for ${actionableModules.length} enabled modules:`), true);
|
|
22
22
|
for (const m of modules) {
|
|
23
23
|
if (actionableModules.includes(m)) {
|
|
24
|
-
io.info((0, cond_format_1.condFormat)(io.supportsAnsiColor, m => chalk_1.default.dim(chalk_1.default.green(m)), `✓ ${m.name}: ${m.shortDescription}`), true);
|
|
24
|
+
io.info((0, cond_format_1.condFormat)(io.supportsAnsiColor, (m) => chalk_1.default.dim(chalk_1.default.green(m)), `✓ ${m.name}: ${m.shortDescription}`), true);
|
|
25
25
|
}
|
|
26
26
|
else if (m.updatable) {
|
|
27
|
-
io.info((0, cond_format_1.condFormat)(io.supportsAnsiColor, m => chalk_1.default.dim(chalk_1.default.red(m)), `𐄂 ${m.name}: ${m.shortDescription} (disabled)`), true);
|
|
27
|
+
io.info((0, cond_format_1.condFormat)(io.supportsAnsiColor, (m) => chalk_1.default.dim(chalk_1.default.red(m)), `𐄂 ${m.name}: ${m.shortDescription} (disabled)`), true);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
for (const m of actionableModules) {
|
|
31
31
|
const fs = dry ? (0, mem_fs_1.create)() : _fs;
|
|
32
|
-
const excludeScaffolding = excludeScaffoldingFunc ? excludeScaffoldingFunc(fs, paths) : [];
|
|
32
|
+
const excludeScaffolding = excludeScaffoldingFunc ? excludeScaffoldingFunc(fs, paths) : { files: [], configKeys: {} };
|
|
33
33
|
(0, module_1.applyModule)(m, modulesEnabled, paramVals, scaffoldDir, fs, paths, excludeScaffolding, true);
|
|
34
34
|
if (dry) {
|
|
35
35
|
const filesWithChanges = fs
|
|
36
36
|
.all()
|
|
37
|
-
.filter(f => f.state && f.state !== 'deleted')
|
|
38
|
-
.filter(f => { var _a; return !(0, node_fs_1.existsSync)(f.path) || (0, node_fs_1.readFileSync)(f.path, 'utf8').toString() !== ((_a = f.contents) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
37
|
+
.filter((f) => f.state && f.state !== 'deleted')
|
|
38
|
+
.filter((f) => { var _a; return !(0, node_fs_1.existsSync)(f.path) || (0, node_fs_1.readFileSync)(f.path, 'utf8').toString() !== ((_a = f.contents) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
39
39
|
if (filesWithChanges.length > 0) {
|
|
40
40
|
io.error(`Module ${m.name} has ${filesWithChanges.length} changed files: ${filesWithChanges
|
|
41
|
-
.map(f => f.path.replace(paths.package() + '/', ''))
|
|
41
|
+
.map((f) => f.path.replace(paths.package() + '/', ''))
|
|
42
42
|
.join(', ')}`, false);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -52,9 +52,9 @@ function auditStepFactory(dry, scaffoldDir, modules, templateParams, excludeScaf
|
|
|
52
52
|
}
|
|
53
53
|
return _fs;
|
|
54
54
|
},
|
|
55
|
-
exposes: modules.map(m => `modules.${m.name}`),
|
|
55
|
+
exposes: modules.map((m) => `modules.${m.name}`),
|
|
56
56
|
getExposed(_paths, _paramProvider) {
|
|
57
|
-
return (0, rename_keys_1.renameKeys)(modulesEnabled, k => `modules.${k}`);
|
|
57
|
+
return (0, rename_keys_1.renameKeys)(modulesEnabled, (k) => `modules.${k}`);
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
}
|
|
@@ -4,7 +4,7 @@ exports.infraStepFactory = void 0;
|
|
|
4
4
|
const module_1 = require("./module");
|
|
5
5
|
const template_param_1 = require("./template-param");
|
|
6
6
|
function infraStepFactory(scaffoldDir, moduleName, modules, templateParams, excludeScaffoldingFunc, moduleStatusCache) {
|
|
7
|
-
const module = modules.find(m => m.name === moduleName);
|
|
7
|
+
const module = modules.find((m) => m.name === moduleName);
|
|
8
8
|
if (!module) {
|
|
9
9
|
throw new Error(`Module ${moduleName} not found`);
|
|
10
10
|
}
|
|
@@ -17,7 +17,7 @@ function infraStepFactory(scaffoldDir, moduleName, modules, templateParams, excl
|
|
|
17
17
|
if (!module.updatable) {
|
|
18
18
|
io.error(`${module.name} is not updatable.`, true);
|
|
19
19
|
}
|
|
20
|
-
const excludeScaffolding = excludeScaffoldingFunc ? excludeScaffoldingFunc(fs, paths) : [];
|
|
20
|
+
const excludeScaffolding = excludeScaffoldingFunc ? excludeScaffoldingFunc(fs, paths) : { files: [], configKeys: {} };
|
|
21
21
|
const initializing = !modulesEnabled[module.name];
|
|
22
22
|
(0, module_1.applyModule)(module, Object.assign(Object.assign({}, modulesEnabled), { [module.name]: true }), paramVals, scaffoldDir, fs, paths, excludeScaffolding, initializing);
|
|
23
23
|
if (moduleStatusCache) {
|
|
@@ -12,22 +12,22 @@ function initStepFactory(scaffoldDir, modules, templateParams, excludeScaffoldin
|
|
|
12
12
|
async run(fs, paths, io, _providers) {
|
|
13
13
|
const paramVals = await (0, template_param_1.promptParamValues)(templateParams, paths, io);
|
|
14
14
|
modulesEnabled = await (0, module_1.promptModulesEnabled)(modules, io);
|
|
15
|
-
const excludeScaffolding = excludeScaffoldingFunc ? excludeScaffoldingFunc(fs, paths) : [];
|
|
15
|
+
const excludeScaffolding = excludeScaffoldingFunc ? excludeScaffoldingFunc(fs, paths) : { files: [], configKeys: {} };
|
|
16
16
|
for (const m of modules) {
|
|
17
|
-
if (modulesEnabled[m.name] && (!m.togglable || !m.dependsOn.some(dep => !modulesEnabled[dep]))) {
|
|
17
|
+
if (modulesEnabled[m.name] && (!m.togglable || !m.dependsOn.some((dep) => !modulesEnabled[dep]))) {
|
|
18
18
|
(0, module_1.applyModule)(m, modulesEnabled, paramVals, scaffoldDir, fs, paths, excludeScaffolding, true);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
if (moduleStatusCache) {
|
|
22
|
-
modules.forEach(m => {
|
|
22
|
+
modules.forEach((m) => {
|
|
23
23
|
(0, module_1.setModuleValue)(m, modulesEnabled[m.name], fs, paths, moduleStatusCache);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
return fs;
|
|
27
27
|
},
|
|
28
|
-
exposes: modules.map(m => `modules.${m.name}`),
|
|
28
|
+
exposes: modules.map((m) => `modules.${m.name}`),
|
|
29
29
|
getExposed(_paths, _paramProvider) {
|
|
30
|
-
return (0, rename_keys_1.renameKeys)(modulesEnabled, k => `modules.${k}`);
|
|
30
|
+
return (0, rename_keys_1.renameKeys)(modulesEnabled, (k) => `modules.${k}`);
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Store } from 'mem-fs';
|
|
2
2
|
import { IO } from 'boilersmith/io';
|
|
3
3
|
import { Paths } from 'boilersmith/paths';
|
|
4
|
-
|
|
4
|
+
import { ExcludeScaffoldingFunc } from './scaffolder';
|
|
5
|
+
declare type FileOwnershipCommon<N extends string> = {
|
|
5
6
|
/**
|
|
6
7
|
* The path to the file
|
|
7
8
|
*/
|
|
@@ -13,16 +14,26 @@ interface FileOwnership {
|
|
|
13
14
|
/**
|
|
14
15
|
* Depends on other modules being enabled (or disabled).
|
|
15
16
|
*/
|
|
16
|
-
moduleDeps?: (
|
|
17
|
-
module:
|
|
17
|
+
moduleDeps?: (N | {
|
|
18
|
+
module: N;
|
|
18
19
|
enabled: boolean;
|
|
19
20
|
})[];
|
|
21
|
+
/**
|
|
22
|
+
* Only create the file if it doesn't exist; do not update existing files.
|
|
23
|
+
*/
|
|
24
|
+
doNotUpdate?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare type FileOwnership<N extends string> = (FileOwnershipCommon<N> & {
|
|
20
27
|
/**
|
|
21
28
|
* If in a monorepo, should the file be placed relative to the monorepo root, and if so, where?
|
|
22
29
|
* If provided, takes priority over destPath.
|
|
23
30
|
*/
|
|
24
|
-
monorepoPath
|
|
25
|
-
|
|
31
|
+
monorepoPath: string;
|
|
32
|
+
/**
|
|
33
|
+
* Only place this file if in a monorepo?
|
|
34
|
+
*/
|
|
35
|
+
requireMonorepo: boolean;
|
|
36
|
+
}) | FileOwnershipCommon<N>;
|
|
26
37
|
interface CommonModule<N extends string> {
|
|
27
38
|
name: N;
|
|
28
39
|
shortDescription: string;
|
|
@@ -34,7 +45,7 @@ interface CommonModule<N extends string> {
|
|
|
34
45
|
/**
|
|
35
46
|
* A list of scaffolding files managed by this module.
|
|
36
47
|
*/
|
|
37
|
-
filesToReplace: (string | FileOwnership)[];
|
|
48
|
+
filesToReplace: (string | FileOwnership<N>)[];
|
|
38
49
|
/**
|
|
39
50
|
* A map of names of JSON files to keys which should be deep-merged from the scaffolding.
|
|
40
51
|
*/
|
|
@@ -62,7 +73,7 @@ interface TogglableModule<N extends string> extends CommonModule<N> {
|
|
|
62
73
|
/**
|
|
63
74
|
* Can only be enabled if these other modules are enabled.
|
|
64
75
|
*/
|
|
65
|
-
dependsOn:
|
|
76
|
+
dependsOn: N[];
|
|
66
77
|
/**
|
|
67
78
|
* On an existing installation, if no information about whether this
|
|
68
79
|
* module is enabled or disabled is cached, infer whether it's enabled
|
|
@@ -78,5 +89,5 @@ export declare type ModuleStatusCache<N extends string> = {
|
|
|
78
89
|
export declare function promptModulesEnabled<N extends string>(modules: Module<N>[], io: IO): Promise<Record<N, boolean>>;
|
|
79
90
|
export declare function currModulesEnabled<N extends string>(modules: Module<N>[], fs: Store, paths: Paths, cache?: ModuleStatusCache<N>): Promise<Record<N, boolean>>;
|
|
80
91
|
export declare function setModuleValue<MN extends string>(module: Module<MN>, enabled: boolean, fs: Store, paths: Paths, cache: ModuleStatusCache<MN>): Promise<void>;
|
|
81
|
-
export declare function applyModule<MN extends string, TN extends string>(module: Module<MN>, modulesEnabled: Record<string, boolean>, paramVals: Record<TN, unknown>, scaffoldDir: string, fs: Store, paths: Paths,
|
|
92
|
+
export declare function applyModule<MN extends string, TN extends string>(module: Module<MN>, modulesEnabled: Record<string, boolean>, paramVals: Record<TN, unknown>, scaffoldDir: string, fs: Store, paths: Paths, excludeScaffolding?: ReturnType<ExcludeScaffoldingFunc>, isInitial?: boolean): Promise<Store>;
|
|
82
93
|
export {};
|
|
@@ -19,7 +19,7 @@ async function promptModulesEnabled(modules, io) {
|
|
|
19
19
|
message: `Advanced Initialization ${(0, cond_format_1.condFormat)(io.supportsAnsiColor, chalk_1.default.dim, '(fine-tune which features are enabled)')}`,
|
|
20
20
|
});
|
|
21
21
|
for (const m of modules) {
|
|
22
|
-
const missingDeps = !m.togglable || m.dependsOn.some(dep => !modulesEnabled[dep]);
|
|
22
|
+
const missingDeps = !m.togglable || m.dependsOn.some((dep) => !modulesEnabled[dep]);
|
|
23
23
|
if (!m.togglable) {
|
|
24
24
|
modulesEnabled[m.name] = true;
|
|
25
25
|
}
|
|
@@ -48,7 +48,7 @@ async function currModulesEnabled(modules, fs, paths, cache) {
|
|
|
48
48
|
for (const m of modules) {
|
|
49
49
|
if (m.togglable) {
|
|
50
50
|
// eslint-disable-next-line no-await-in-loop
|
|
51
|
-
const isEnabled = (_a = await (cache === null || cache === void 0 ? void 0 : cache.get(m, fs, paths))) !== null && _a !== void 0 ? _a : await ((_b = m.inferEnabled) === null || _b === void 0 ? void 0 : _b.call(m, fs, paths));
|
|
51
|
+
const isEnabled = (_a = (await (cache === null || cache === void 0 ? void 0 : cache.get(m, fs, paths)))) !== null && _a !== void 0 ? _a : (await ((_b = m.inferEnabled) === null || _b === void 0 ? void 0 : _b.call(m, fs, paths)));
|
|
52
52
|
modulesEnabled[m.name] = isEnabled !== null && isEnabled !== void 0 ? isEnabled : m.defaultEnabled;
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -64,21 +64,23 @@ async function setModuleValue(module, enabled, fs, paths, cache) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
exports.setModuleValue = setModuleValue;
|
|
67
|
-
// eslint-disable-next-line max-params
|
|
68
|
-
async function applyModule(module, modulesEnabled, paramVals, scaffoldDir, fs, paths,
|
|
69
|
-
|
|
67
|
+
// eslint-disable-next-line max-params,complexity
|
|
68
|
+
async function applyModule(module, modulesEnabled, paramVals, scaffoldDir, fs, paths,
|
|
69
|
+
// eslint-disable-next-line unicorn/no-object-as-default-parameter
|
|
70
|
+
excludeScaffolding = { files: [], configKeys: {} }, isInitial = false) {
|
|
71
|
+
var _a, _b;
|
|
70
72
|
const fsEditor = (0, mem_fs_editor_1.create)(fs);
|
|
71
73
|
// Validate that module can be enabled
|
|
72
74
|
if (!(modulesEnabled === null || modulesEnabled === void 0 ? void 0 : modulesEnabled[module.name])) {
|
|
73
75
|
throw new Error(`Could not apply module "${module.name}", because it is not enabled in the provided module statuses.`);
|
|
74
76
|
}
|
|
75
77
|
// Validate that dependencies are enabled
|
|
76
|
-
const missingDeps = module.togglable ? module.dependsOn.filter(dep => !modulesEnabled[dep]) : [];
|
|
78
|
+
const missingDeps = module.togglable ? module.dependsOn.filter((dep) => !modulesEnabled[dep]) : [];
|
|
77
79
|
if (missingDeps.length > 0) {
|
|
78
80
|
throw new Error(`Could not apply module "${module.name}", because the following dependency modules are missing: "${missingDeps.join(', ')}".`);
|
|
79
81
|
}
|
|
80
82
|
// Validate that all needed params are present
|
|
81
|
-
const missingParams = module.needsTemplateParams.filter(p => !(p in paramVals));
|
|
83
|
+
const missingParams = module.needsTemplateParams.filter((p) => !(p in paramVals));
|
|
82
84
|
if (missingParams.length > 0) {
|
|
83
85
|
throw new Error(`Could not apply module "${module.name}", because the following params are missing: "${missingParams.join(', ')}".`);
|
|
84
86
|
}
|
|
@@ -89,25 +91,36 @@ async function applyModule(module, modulesEnabled, paramVals, scaffoldDir, fs, p
|
|
|
89
91
|
params: paramVals,
|
|
90
92
|
modules: modulesEnabled,
|
|
91
93
|
};
|
|
92
|
-
const tplDataFlat = Object.assign(Object.assign({}, (0, rename_keys_1.renameKeys)(tplData.modules, k => `modules.${k}`)), (0, rename_keys_1.renameKeys)(tplData.params, k => `params.${k}`));
|
|
94
|
+
const tplDataFlat = Object.assign(Object.assign({}, (0, rename_keys_1.renameKeys)(tplData.modules, (k) => `modules.${k}`)), (0, rename_keys_1.renameKeys)(tplData.params, (k) => `params.${k}`));
|
|
93
95
|
for (const file of module.filesToReplace) {
|
|
94
96
|
const path = typeof file === 'string' ? file : file.path;
|
|
95
97
|
const moduleDeps = typeof file === 'string' ? [] : (_a = file.moduleDeps) !== null && _a !== void 0 ? _a : [];
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
const copyToIfMonorepo = typeof file !== 'string' && 'monorepoPath' in file && file.monorepoPath
|
|
99
|
+
? paths.monorepo((0, clone_and_fill_1.cloneAndFill)(file.monorepoPath, tplDataFlat))
|
|
100
|
+
: undefined;
|
|
101
|
+
const copyTo = copyToIfMonorepo !== null && copyToIfMonorepo !== void 0 ? copyToIfMonorepo : paths.package(typeof file !== 'string' && file.destPath ? (0, clone_and_fill_1.cloneAndFill)(file.destPath, tplDataFlat) : path);
|
|
102
|
+
if (typeof file !== 'string' && file.doNotUpdate && fsEditor.exists(copyTo)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (typeof file !== 'string' && 'requireMonorepo' in file && file.requireMonorepo && paths.monorepo() === null) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (excludeScaffolding.files.includes(path) ||
|
|
109
|
+
moduleDeps.some((dep) => {
|
|
110
|
+
const depName = typeof dep === 'string' ? dep : dep.module;
|
|
111
|
+
const enabled = modulesEnabled[depName];
|
|
112
|
+
return typeof dep === 'string' || dep.enabled ? !enabled : enabled;
|
|
113
|
+
})) {
|
|
114
|
+
continue;
|
|
104
115
|
}
|
|
116
|
+
fsEditor.copyTpl((0, node_path_1.resolve)(scaffoldDir, path), copyTo, tplData);
|
|
105
117
|
}
|
|
106
118
|
const jsonPaths = (0, clone_and_fill_1.cloneAndFill)(module.jsonToAugment, tplDataFlat);
|
|
107
119
|
for (const jsonPath of Object.keys(jsonPaths)) {
|
|
108
120
|
const scaffoldContents = (0, read_tpl_1.readTpl)((0, node_path_1.resolve)(scaffoldDir, jsonPath), tplData);
|
|
109
121
|
const scaffoldContentsJson = JSON.parse(scaffoldContents);
|
|
110
|
-
const
|
|
122
|
+
const excludeKeys = (0, clone_and_fill_1.cloneAndFill)((_b = excludeScaffolding.configKeys[jsonPath]) !== null && _b !== void 0 ? _b : [], tplDataFlat);
|
|
123
|
+
const fieldsToAugment = jsonPaths[jsonPath].filter((key) => !excludeKeys.includes(key));
|
|
111
124
|
const relevant = (0, pick_deep_1.default)(scaffoldContentsJson, fieldsToAugment);
|
|
112
125
|
fsEditor.extendJSON(paths.package(jsonPath), relevant, undefined, 4);
|
|
113
126
|
}
|
|
@@ -4,7 +4,10 @@ import { DefaultProviders, Step } from '../step-manager';
|
|
|
4
4
|
import { Module, ModuleStatusCache } from './module';
|
|
5
5
|
import { TemplateParam } from './template-param';
|
|
6
6
|
import { IO } from 'boilersmith/io';
|
|
7
|
-
export declare type ExcludeScaffoldingFunc = (fs: Store, paths: Paths) =>
|
|
7
|
+
export declare type ExcludeScaffoldingFunc = (fs: Store, paths: Paths) => {
|
|
8
|
+
files: string[];
|
|
9
|
+
configKeys: Record<string, string[]>;
|
|
10
|
+
};
|
|
8
11
|
export declare class Scaffolder<TN extends string = string, MN extends string = string> {
|
|
9
12
|
private templateParams;
|
|
10
13
|
private modules;
|
|
@@ -27,8 +27,8 @@ class Scaffolder {
|
|
|
27
27
|
}
|
|
28
28
|
registerTemplateParam(templateParam) {
|
|
29
29
|
if ((0, template_param_1.isComputedParam)(templateParam)) {
|
|
30
|
-
const currParams = new Set(this.templateParams.map(p => (0, template_param_1.getParamName)(p)));
|
|
31
|
-
const missingDeps = templateParam.uses.filter(dep => !currParams.has(dep));
|
|
30
|
+
const currParams = new Set(this.templateParams.map((p) => (0, template_param_1.getParamName)(p)));
|
|
31
|
+
const missingDeps = templateParam.uses.filter((dep) => !currParams.has(dep));
|
|
32
32
|
if (missingDeps.length > 0) {
|
|
33
33
|
throw new Error(`Computed template param "${(0, template_param_1.getParamName)(templateParam)}" is missing dependency params: "${missingDeps.join(', ')}".`);
|
|
34
34
|
}
|
|
@@ -56,7 +56,7 @@ class Scaffolder {
|
|
|
56
56
|
}
|
|
57
57
|
moduleFiles(moduleName) {
|
|
58
58
|
var _a, _b;
|
|
59
|
-
return (_b = (_a = this.modules.find(m => m.name === moduleName)) === null || _a === void 0 ? void 0 : _a.filesToReplace.map(f => typeof f === 'string' ? f : f.path)) !== null && _b !== void 0 ? _b : [];
|
|
59
|
+
return (_b = (_a = this.modules.find((m) => m.name === moduleName)) === null || _a === void 0 ? void 0 : _a.filesToReplace.map((f) => (typeof f === 'string' ? f : f.path))) !== null && _b !== void 0 ? _b : [];
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Confirm that all files and configuration keys in the scaffolding dir
|
|
@@ -66,13 +66,13 @@ class Scaffolder {
|
|
|
66
66
|
async validate() {
|
|
67
67
|
const errors = [];
|
|
68
68
|
// Generate template data for future checks
|
|
69
|
-
const paramVals = Object.fromEntries(this.templateParams.map(param => [(0, template_param_1.getParamName)(param), 'TEST']));
|
|
70
|
-
const modulesEnabled = Object.fromEntries(this.modules.map(module => [module.name, true]));
|
|
69
|
+
const paramVals = Object.fromEntries(this.templateParams.map((param) => [(0, template_param_1.getParamName)(param), 'TEST']));
|
|
70
|
+
const modulesEnabled = Object.fromEntries(this.modules.map((module) => [module.name, true]));
|
|
71
71
|
const tplData = { params: paramVals, modules: modulesEnabled };
|
|
72
|
-
const tplDataFlat = Object.assign(Object.assign({}, (0, rename_keys_1.renameKeys)(tplData.modules, k => `modules.${k}`)), (0, rename_keys_1.renameKeys)(tplData.params, k => `params.${k}`));
|
|
73
|
-
const moduleNames = new Set(this.modules.map(m => m.name));
|
|
72
|
+
const tplDataFlat = Object.assign(Object.assign({}, (0, rename_keys_1.renameKeys)(tplData.modules, (k) => `modules.${k}`)), (0, rename_keys_1.renameKeys)(tplData.params, (k) => `params.${k}`));
|
|
73
|
+
const moduleNames = new Set(this.modules.map((m) => m.name));
|
|
74
74
|
for (const module of this.modules) {
|
|
75
|
-
const missingDeps = module.togglable ? module.dependsOn.filter(dep => !moduleNames.has(dep)) : [];
|
|
75
|
+
const missingDeps = module.togglable ? module.dependsOn.filter((dep) => !moduleNames.has(dep)) : [];
|
|
76
76
|
if (missingDeps.length > 0) {
|
|
77
77
|
errors.push(`Module "${module.name}" depends on modules that are not registered: "${missingDeps.join(', ')}".`);
|
|
78
78
|
}
|
|
@@ -81,23 +81,23 @@ class Scaffolder {
|
|
|
81
81
|
const configKeysToOwnerModules = new Map();
|
|
82
82
|
const templateParamsToUsingModules = new Map();
|
|
83
83
|
for (const module of this.modules) {
|
|
84
|
-
module.filesToReplace.forEach(file => {
|
|
84
|
+
module.filesToReplace.forEach((file) => {
|
|
85
85
|
var _a;
|
|
86
86
|
const path = typeof file === 'string' ? file : file.path;
|
|
87
87
|
const currModules = (_a = filesToOwnerModules.get(path)) !== null && _a !== void 0 ? _a : [];
|
|
88
88
|
filesToOwnerModules.set(path, [...currModules, module.name]);
|
|
89
89
|
});
|
|
90
|
-
module.needsTemplateParams.forEach(paramName => {
|
|
90
|
+
module.needsTemplateParams.forEach((paramName) => {
|
|
91
91
|
var _a;
|
|
92
92
|
const currModules = (_a = filesToOwnerModules.get(paramName)) !== null && _a !== void 0 ? _a : [];
|
|
93
93
|
templateParamsToUsingModules.set(paramName, [...currModules, module.name]);
|
|
94
94
|
});
|
|
95
|
-
Object.keys(module.jsonToAugment).forEach(jsonPath => {
|
|
95
|
+
Object.keys(module.jsonToAugment).forEach((jsonPath) => {
|
|
96
96
|
var _a;
|
|
97
97
|
const ownedKeys = (0, clone_and_fill_1.cloneAndFill)(module.jsonToAugment, tplDataFlat)[jsonPath];
|
|
98
98
|
const currJsonData = (_a = configKeysToOwnerModules.get(jsonPath)) !== null && _a !== void 0 ? _a : { fileOwners: [], keyOwners: new Map() };
|
|
99
99
|
currJsonData.fileOwners.push(module.name);
|
|
100
|
-
ownedKeys.forEach(key => {
|
|
100
|
+
ownedKeys.forEach((key) => {
|
|
101
101
|
var _a;
|
|
102
102
|
const currModules = (_a = currJsonData.keyOwners.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
103
103
|
currJsonData.keyOwners.set(key, [...currModules, module.name]);
|
|
@@ -109,46 +109,46 @@ class Scaffolder {
|
|
|
109
109
|
const moduleOwnedFiles = [...filesToOwnerModules.keys()];
|
|
110
110
|
const moduleOwnedJsonConfs = new Set(configKeysToOwnerModules.keys());
|
|
111
111
|
moduleOwnedFiles
|
|
112
|
-
.filter(path => moduleOwnedJsonConfs.has(path))
|
|
113
|
-
.forEach(path => {
|
|
112
|
+
.filter((path) => moduleOwnedJsonConfs.has(path))
|
|
113
|
+
.forEach((path) => {
|
|
114
114
|
var _a, _b;
|
|
115
115
|
const fileModules = (_a = filesToOwnerModules.get(path)) === null || _a === void 0 ? void 0 : _a.join(', ');
|
|
116
116
|
const keyModules = (_b = configKeysToOwnerModules.get(path)) === null || _b === void 0 ? void 0 : _b.fileOwners.join(', ');
|
|
117
117
|
errors.push(`File "${path}" is owned by modules: "${fileModules}". However, it also has keys that are owned by modules: "${keyModules}".`);
|
|
118
118
|
});
|
|
119
119
|
// Ensure that all owned files exist in the filesystem.
|
|
120
|
-
const scaffoldingFilePaths = new Set((await (0, globby_1.default)((0, node_path_1.resolve)(this.scaffoldDir, '**/*'), { dot: true })).map(p => p.replace(`${this.scaffoldDir}/`, '')).filter(p => p !== ''));
|
|
120
|
+
const scaffoldingFilePaths = new Set((await (0, globby_1.default)((0, node_path_1.resolve)(this.scaffoldDir, '**/*'), { dot: true })).map((p) => p.replace(`${this.scaffoldDir}/`, '')).filter((p) => p !== ''));
|
|
121
121
|
moduleOwnedFiles
|
|
122
|
-
.filter(path => !scaffoldingFilePaths.has(path))
|
|
123
|
-
.forEach(path => {
|
|
122
|
+
.filter((path) => !scaffoldingFilePaths.has(path))
|
|
123
|
+
.forEach((path) => {
|
|
124
124
|
var _a;
|
|
125
125
|
const fileModules = (_a = filesToOwnerModules.get(path)) === null || _a === void 0 ? void 0 : _a.join(', ');
|
|
126
126
|
errors.push(`File "${path}" is owned by modules: "${fileModules}", but it doesn't exist in the scaffolding directory.`);
|
|
127
127
|
});
|
|
128
128
|
[...moduleOwnedJsonConfs]
|
|
129
|
-
.filter(path => !scaffoldingFilePaths.has(path))
|
|
130
|
-
.forEach(path => {
|
|
129
|
+
.filter((path) => !scaffoldingFilePaths.has(path))
|
|
130
|
+
.forEach((path) => {
|
|
131
131
|
var _a;
|
|
132
132
|
const keyModules = (_a = configKeysToOwnerModules.get(path)) === null || _a === void 0 ? void 0 : _a.fileOwners.join(', ');
|
|
133
133
|
errors.push(`File "${path}" has keys owned by modules: "${keyModules}", but it doesn't exist in the scaffolding directory.`);
|
|
134
134
|
});
|
|
135
135
|
// Ensure that all files in the filesystem are owned by at least one module.
|
|
136
136
|
[...scaffoldingFilePaths]
|
|
137
|
-
.filter(path => !filesToOwnerModules.has(path) && !configKeysToOwnerModules.has(path))
|
|
138
|
-
.forEach(path => {
|
|
137
|
+
.filter((path) => !filesToOwnerModules.has(path) && !configKeysToOwnerModules.has(path))
|
|
138
|
+
.forEach((path) => {
|
|
139
139
|
errors.push(`File "${path}" is not owned by any module.`);
|
|
140
140
|
});
|
|
141
141
|
// Ensure that every template param is used by at least one module.
|
|
142
142
|
this.templateParams
|
|
143
|
-
.filter(p => !templateParamsToUsingModules.has((0, template_param_1.getParamName)(p)))
|
|
144
|
-
.forEach(p => {
|
|
143
|
+
.filter((p) => !templateParamsToUsingModules.has((0, template_param_1.getParamName)(p)))
|
|
144
|
+
.forEach((p) => {
|
|
145
145
|
errors.push(`Template param "${(0, template_param_1.getParamName)(p)}" is defined, but not used by any modules.`);
|
|
146
146
|
});
|
|
147
147
|
// Ensure that every module's needed template params are provided.
|
|
148
|
-
const providedParams = new Set(this.templateParams.map(p => (0, template_param_1.getParamName)(p)));
|
|
148
|
+
const providedParams = new Set(this.templateParams.map((p) => (0, template_param_1.getParamName)(p)));
|
|
149
149
|
[...templateParamsToUsingModules.keys()]
|
|
150
|
-
.filter(paramName => !providedParams.has(paramName))
|
|
151
|
-
.forEach(paramName => {
|
|
150
|
+
.filter((paramName) => !providedParams.has(paramName))
|
|
151
|
+
.forEach((paramName) => {
|
|
152
152
|
var _a;
|
|
153
153
|
const paramModules = (_a = templateParamsToUsingModules.get(paramName)) === null || _a === void 0 ? void 0 : _a.join(', ');
|
|
154
154
|
errors.push(`Template param "${paramName}" is used by modules: "${paramModules}", but is not provided.`);
|
|
@@ -170,8 +170,8 @@ class Scaffolder {
|
|
|
170
170
|
json = JSON.parse(contents);
|
|
171
171
|
const keys = new Set((0, json_leaf_paths_1.jsonLeafPaths)(json));
|
|
172
172
|
[...keys]
|
|
173
|
-
.filter(k => !ownerData.keyOwners.has(k))
|
|
174
|
-
.forEach(k => {
|
|
173
|
+
.filter((k) => !ownerData.keyOwners.has(k))
|
|
174
|
+
.forEach((k) => {
|
|
175
175
|
errors.push(`Key "${k}" in file "${path}" is not owned by any module.`);
|
|
176
176
|
});
|
|
177
177
|
[...ownerData.keyOwners.entries()]
|
|
@@ -195,7 +195,7 @@ class Scaffolder {
|
|
|
195
195
|
throw new Error(errors.join('\n'));
|
|
196
196
|
}
|
|
197
197
|
// Ensure that all files can be resolved with ejs using provided template variables.
|
|
198
|
-
scaffoldingFilePaths.forEach(path => {
|
|
198
|
+
scaffoldingFilePaths.forEach((path) => {
|
|
199
199
|
(0, read_tpl_1.readTpl)((0, node_path_1.resolve)(this.scaffoldDir, path), tplData);
|
|
200
200
|
});
|
|
201
201
|
}
|
|
@@ -11,7 +11,7 @@ interface PromptTemplateParam<T, N extends string = string> {
|
|
|
11
11
|
}
|
|
12
12
|
interface ComputedTemplateParam<T, N extends string = string> {
|
|
13
13
|
name: N;
|
|
14
|
-
uses:
|
|
14
|
+
uses: N[];
|
|
15
15
|
compute: (paths: Paths, ...args: any[]) => Promise<T>;
|
|
16
16
|
}
|
|
17
17
|
export declare type TemplateParam<T = unknown, N extends string = string> = PromptTemplateParam<T, N> | ComputedTemplateParam<T, N>;
|
|
@@ -17,7 +17,7 @@ async function withComputedParamValues(params, paths, paramVals) {
|
|
|
17
17
|
const vals = Object.assign({}, paramVals);
|
|
18
18
|
const computedParams = params.filter(isComputedParam);
|
|
19
19
|
for (const p of computedParams) {
|
|
20
|
-
const depValues = p.uses.map(key => vals[key]);
|
|
20
|
+
const depValues = p.uses.map((key) => vals[key]);
|
|
21
21
|
// eslint-disable-next-line no-await-in-loop
|
|
22
22
|
vals[p.name] = await p.compute(paths, ...depValues);
|
|
23
23
|
}
|
|
@@ -39,7 +39,7 @@ async function currParamValues(params, fs, paths, io) {
|
|
|
39
39
|
const paramVals = {};
|
|
40
40
|
for (const p of promptParams) {
|
|
41
41
|
// eslint-disable-next-line no-await-in-loop
|
|
42
|
-
paramVals[p.prompt.name] = (_a = await p.getCurrVal(fs, paths)) !== null && _a !== void 0 ? _a : await io.getParam(p.prompt);
|
|
42
|
+
paramVals[p.prompt.name] = (_a = (await p.getCurrVal(fs, paths))) !== null && _a !== void 0 ? _a : (await io.getParam(p.prompt));
|
|
43
43
|
}
|
|
44
44
|
return withComputedParamValues(params, paths, paramVals);
|
|
45
45
|
}
|
|
@@ -72,7 +72,6 @@ export declare class StepManager<Providers extends DefaultProviders> {
|
|
|
72
72
|
run(paths: Paths, io: IO, providers: Providers, dry?: boolean): Promise<StepsResult>;
|
|
73
73
|
protected stepShouldRun(storedStep: StoredStep<Providers>, io: IO, packagePath?: string): Promise<boolean>;
|
|
74
74
|
protected runStep(storedStep: StoredStep<Providers>, paths: Paths, io: IO, providers: Providers, packagePath?: string, fs?: Store): Promise<Store>;
|
|
75
|
-
protected commit(fs: Store): Promise<boolean>;
|
|
76
75
|
}
|
|
77
76
|
export declare class AtomicStepManager<Providers = DefaultProviders> extends StepManager<Providers> {
|
|
78
77
|
protected steps: StoredStep<Providers>[];
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AtomicStepManager = exports.StepManager = void 0;
|
|
4
4
|
/* eslint-disable no-await-in-loop */
|
|
5
5
|
const mem_fs_1 = require("mem-fs");
|
|
6
|
-
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
7
6
|
const exposed_param_manager_1 = require("./exposed-param-manager");
|
|
8
|
-
const
|
|
7
|
+
const commit_async_1 = require("./utils/commit-async");
|
|
8
|
+
const formatDependencies = (strings) => strings.map((s) => `"${s}"`).join(', ');
|
|
9
9
|
class StepManager {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.steps = [];
|
|
@@ -37,7 +37,7 @@ class StepManager {
|
|
|
37
37
|
return this;
|
|
38
38
|
}
|
|
39
39
|
validateDependencies(step, dependencies, mapPaths) {
|
|
40
|
-
const missingDependencySteps = dependencies.map(dep => dep.sourceStep).filter(stepName => !this.namedSteps.has(stepName));
|
|
40
|
+
const missingDependencySteps = dependencies.map((dep) => dep.sourceStep).filter((stepName) => !this.namedSteps.has(stepName));
|
|
41
41
|
if (missingDependencySteps.length > 0) {
|
|
42
42
|
throw new Error(`Step of type "${step.type}" depends on nonexistent named steps ${formatDependencies(missingDependencySteps)}`);
|
|
43
43
|
}
|
|
@@ -52,7 +52,7 @@ class StepManager {
|
|
|
52
52
|
if (mapPaths.length === 0 && (sourceStep === null || sourceStep === void 0 ? void 0 : sourceStep.mapPaths.length)) {
|
|
53
53
|
throw new Error(`Non path-mapped step of type "${step.type}" may not depend on path-mapped step "${sourceStep === null || sourceStep === void 0 ? void 0 : sourceStep.name}".`);
|
|
54
54
|
}
|
|
55
|
-
const missingMapPathsDeps = mapPaths.filter(p => sourceStep && !sourceStep.mapPaths.includes(p));
|
|
55
|
+
const missingMapPathsDeps = mapPaths.filter((p) => sourceStep && !sourceStep.mapPaths.includes(p));
|
|
56
56
|
if (sourceStep && (missingMapPathsDeps === null || missingMapPathsDeps === void 0 ? void 0 : missingMapPathsDeps.length) && sourceStep.mapPaths.length > 0) {
|
|
57
57
|
throw new Error(`Step of type "${step.type}" (A) depends on named step: "${sourceStep.name}" (B), but is mapped across some paths that (B) is not: "${missingMapPathsDeps.join(', ')}"`);
|
|
58
58
|
}
|
|
@@ -62,7 +62,7 @@ class StepManager {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
async run(paths, io, providers, dry = false) {
|
|
65
|
-
if (dry && this.steps.some(s => !(s instanceof AtomicStepManager) && !s.step.composable)) {
|
|
65
|
+
if (dry && this.steps.some((s) => !(s instanceof AtomicStepManager) && !s.step.composable)) {
|
|
66
66
|
throw new Error('Cannot dry run, as this step manager has non-composable steps.');
|
|
67
67
|
}
|
|
68
68
|
const stepNames = [];
|
|
@@ -72,7 +72,7 @@ class StepManager {
|
|
|
72
72
|
return;
|
|
73
73
|
const fs = await this.runStep(step, paths, io, providers, packagePath);
|
|
74
74
|
if (!dry) {
|
|
75
|
-
await
|
|
75
|
+
await (0, commit_async_1.commitAsync)(fs);
|
|
76
76
|
}
|
|
77
77
|
stepNames.push(packagePath ? `${step.step.type} (${packagePath})` : step.step.type);
|
|
78
78
|
};
|
|
@@ -139,9 +139,9 @@ class StepManager {
|
|
|
139
139
|
const sourceStep = this.namedSteps.get(dep.sourceStep);
|
|
140
140
|
let depValue;
|
|
141
141
|
depValue =
|
|
142
|
-
dep.exposedName === '__succeeded'
|
|
143
|
-
this.exposedParams.stepRan(dep.sourceStep, packagePath)
|
|
144
|
-
this.exposedParams.get(dep.sourceStep, dep.exposedName, (sourceStep === null || sourceStep === void 0 ? void 0 : sourceStep.mapPaths.length) ? packagePath : undefined);
|
|
142
|
+
dep.exposedName === '__succeeded'
|
|
143
|
+
? this.exposedParams.stepRan(dep.sourceStep, packagePath)
|
|
144
|
+
: this.exposedParams.get(dep.sourceStep, dep.exposedName, (sourceStep === null || sourceStep === void 0 ? void 0 : sourceStep.mapPaths.length) ? packagePath : undefined);
|
|
145
145
|
if (dep.modifier) {
|
|
146
146
|
depValue = dep.modifier(depValue);
|
|
147
147
|
}
|
|
@@ -156,16 +156,6 @@ class StepManager {
|
|
|
156
156
|
}
|
|
157
157
|
return newFs;
|
|
158
158
|
}
|
|
159
|
-
async commit(fs) {
|
|
160
|
-
return new Promise((resolve, _reject) => {
|
|
161
|
-
(0, mem_fs_editor_1.create)(fs).commit(err => {
|
|
162
|
-
if (err) {
|
|
163
|
-
throw new Error(err);
|
|
164
|
-
}
|
|
165
|
-
resolve(true);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
159
|
}
|
|
170
160
|
exports.StepManager = StepManager;
|
|
171
161
|
class AtomicStepManager extends StepManager {
|
|
@@ -222,7 +212,7 @@ class AtomicStepManager extends StepManager {
|
|
|
222
212
|
};
|
|
223
213
|
}
|
|
224
214
|
if (!dry) {
|
|
225
|
-
await
|
|
215
|
+
await (0, commit_async_1.commitAsync)(fs);
|
|
226
216
|
}
|
|
227
217
|
return {
|
|
228
218
|
succeeded: true,
|
|
@@ -38,7 +38,7 @@ class BaseStubStep {
|
|
|
38
38
|
}
|
|
39
39
|
async compileParams(fs, paths, io) {
|
|
40
40
|
const params = await this.precompileParams(fs, paths, io);
|
|
41
|
-
const paramDefs = this.schema.params.filter(param => !this.implicitParams.includes(param.name) && !Object.keys(params).includes(param.name));
|
|
41
|
+
const paramDefs = this.schema.params.filter((param) => !this.implicitParams.includes(param.name) && !Object.keys(params).includes(param.name));
|
|
42
42
|
for (const paramDef of paramDefs) {
|
|
43
43
|
// eslint-disable-next-line no-await-in-loop
|
|
44
44
|
params[paramDef.name] = await io.getParam(paramDef);
|
|
@@ -11,7 +11,7 @@ function cloneAndFill(obj, params) {
|
|
|
11
11
|
if (typeof obj === 'string')
|
|
12
12
|
return fill(obj, params);
|
|
13
13
|
if (Array.isArray(obj))
|
|
14
|
-
return obj.map(v => recursiveCopyAndFill(v, params));
|
|
14
|
+
return obj.map((v) => recursiveCopyAndFill(v, params));
|
|
15
15
|
// eslint-disable-next-line no-new-object
|
|
16
16
|
if (obj !== new Object(obj))
|
|
17
17
|
return obj;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commitAsync = void 0;
|
|
4
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
5
|
+
async function commitAsync(fs) {
|
|
6
|
+
return new Promise((resolve, _reject) => {
|
|
7
|
+
(0, mem_fs_editor_1.create)(fs).commit((err) => {
|
|
8
|
+
if (err) {
|
|
9
|
+
throw new Error(err);
|
|
10
|
+
}
|
|
11
|
+
resolve(true);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.commitAsync = commitAsync;
|
|
@@ -11,6 +11,6 @@ export default class AuditInfra extends BaseCommand {
|
|
|
11
11
|
name: string;
|
|
12
12
|
description: string;
|
|
13
13
|
}[];
|
|
14
|
-
protected steps(stepManager: StepManager<FlarumProviders
|
|
14
|
+
protected steps(stepManager: StepManager<FlarumProviders>, extRoot: string): StepManager<FlarumProviders>;
|
|
15
15
|
protected additionalPreRunChecks(extRoot: string): Promise<void>;
|
|
16
16
|
}
|