@antelopejs/core 1.10.3 → 1.12.0
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 +1 -1
- package/dist/core/cli/cancellation.d.ts +4 -0
- package/dist/core/cli/cancellation.js +19 -0
- package/dist/core/cli/cancellation.js.map +1 -0
- package/dist/core/cli/cli-ui.d.ts +8 -13
- package/dist/core/cli/cli-ui.js +36 -116
- package/dist/core/cli/cli-ui.js.map +1 -1
- package/dist/core/cli/command.d.ts +11 -0
- package/dist/core/cli/command.js +30 -4
- package/dist/core/cli/command.js.map +1 -1
- package/dist/core/cli/commands/config/get-action.d.ts +6 -0
- package/dist/core/cli/commands/config/get-action.js +39 -0
- package/dist/core/cli/commands/config/get-action.js.map +1 -0
- package/dist/core/cli/commands/config/get.d.ts +2 -1
- package/dist/core/cli/commands/config/get.js +50 -33
- package/dist/core/cli/commands/config/get.js.map +1 -1
- package/dist/core/cli/commands/config/index.js +2 -2
- package/dist/core/cli/commands/config/index.js.map +1 -1
- package/dist/core/cli/commands/config/keys.d.ts +3 -0
- package/dist/core/cli/commands/config/keys.js +13 -0
- package/dist/core/cli/commands/config/keys.js.map +1 -0
- package/dist/core/cli/commands/config/reset-action.d.ts +5 -0
- package/dist/core/cli/commands/config/reset-action.js +45 -0
- package/dist/core/cli/commands/config/reset-action.js.map +1 -0
- package/dist/core/cli/commands/config/reset.js +13 -49
- package/dist/core/cli/commands/config/reset.js.map +1 -1
- package/dist/core/cli/commands/config/set-action.d.ts +1 -0
- package/dist/core/cli/commands/config/set-action.js +24 -0
- package/dist/core/cli/commands/config/set-action.js.map +1 -0
- package/dist/core/cli/commands/config/set.js +48 -34
- package/dist/core/cli/commands/config/set.js.map +1 -1
- package/dist/core/cli/commands/config/show-action.d.ts +6 -0
- package/dist/core/cli/commands/config/show-action.js +38 -0
- package/dist/core/cli/commands/config/show-action.js.map +1 -0
- package/dist/core/cli/commands/config/show.d.ts +2 -1
- package/dist/core/cli/commands/config/show.js +45 -23
- package/dist/core/cli/commands/config/show.js.map +1 -1
- package/dist/core/cli/commands/module/index.js +2 -1
- package/dist/core/cli/commands/module/index.js.map +1 -1
- package/dist/core/cli/commands/module/init-action.d.ts +20 -0
- package/dist/core/cli/commands/module/init-action.js +311 -0
- package/dist/core/cli/commands/module/init-action.js.map +1 -0
- package/dist/core/cli/commands/module/init.d.ts +0 -5
- package/dist/core/cli/commands/module/init.js +29 -168
- package/dist/core/cli/commands/module/init.js.map +1 -1
- package/dist/core/cli/commands/module/test-action.d.ts +5 -0
- package/dist/core/cli/commands/module/test-action.js +45 -0
- package/dist/core/cli/commands/module/test-action.js.map +1 -0
- package/dist/core/cli/commands/module/test.d.ts +0 -5
- package/dist/core/cli/commands/module/test.js +51 -30
- package/dist/core/cli/commands/module/test.js.map +1 -1
- package/dist/core/cli/commands/plugins-action.d.ts +7 -0
- package/dist/core/cli/commands/plugins-action.js +17 -0
- package/dist/core/cli/commands/plugins-action.js.map +1 -0
- package/dist/core/cli/commands/plugins.d.ts +2 -1
- package/dist/core/cli/commands/plugins.js +58 -25
- package/dist/core/cli/commands/plugins.js.map +1 -1
- package/dist/core/cli/commands/project/build-action.d.ts +7 -0
- package/dist/core/cli/commands/project/build-action.js +54 -0
- package/dist/core/cli/commands/project/build-action.js.map +1 -0
- package/dist/core/cli/commands/project/build.js +48 -64
- package/dist/core/cli/commands/project/build.js.map +1 -1
- package/dist/core/cli/commands/project/dev-action.d.ts +13 -0
- package/dist/core/cli/commands/project/dev-action.js +231 -0
- package/dist/core/cli/commands/project/dev-action.js.map +1 -0
- package/dist/core/cli/commands/project/dev.d.ts +1 -2
- package/dist/core/cli/commands/project/dev.js +28 -206
- package/dist/core/cli/commands/project/dev.js.map +1 -1
- package/dist/core/cli/commands/project/index.js +2 -2
- package/dist/core/cli/commands/project/index.js.map +1 -1
- package/dist/core/cli/commands/project/init-action.d.ts +10 -0
- package/dist/core/cli/commands/project/init-action.js +183 -0
- package/dist/core/cli/commands/project/init-action.js.map +1 -0
- package/dist/core/cli/commands/project/init.js +62 -111
- package/dist/core/cli/commands/project/init.js.map +1 -1
- package/dist/core/cli/commands/project/logging/index.js +2 -2
- package/dist/core/cli/commands/project/logging/index.js.map +1 -1
- package/dist/core/cli/commands/project/logging/logging-draft.d.ts +14 -0
- package/dist/core/cli/commands/project/logging/logging-draft.js +34 -0
- package/dist/core/cli/commands/project/logging/logging-draft.js.map +1 -0
- package/dist/core/cli/commands/project/logging/set-action.d.ts +2 -0
- package/dist/core/cli/commands/project/logging/set-action.js +217 -0
- package/dist/core/cli/commands/project/logging/set-action.js.map +1 -0
- package/dist/core/cli/commands/project/logging/set-operations.d.ts +24 -0
- package/dist/core/cli/commands/project/logging/set-operations.js +115 -0
- package/dist/core/cli/commands/project/logging/set-operations.js.map +1 -0
- package/dist/core/cli/commands/project/logging/set-usage.d.ts +8 -0
- package/dist/core/cli/commands/project/logging/set-usage.js +71 -0
- package/dist/core/cli/commands/project/logging/set-usage.js.map +1 -0
- package/dist/core/cli/commands/project/logging/set.js +98 -355
- package/dist/core/cli/commands/project/logging/set.js.map +1 -1
- package/dist/core/cli/commands/project/logging/show-action.d.ts +8 -0
- package/dist/core/cli/commands/project/logging/show-action.js +71 -0
- package/dist/core/cli/commands/project/logging/show-action.js.map +1 -0
- package/dist/core/cli/commands/project/logging/show.d.ts +2 -1
- package/dist/core/cli/commands/project/logging/show.js +54 -89
- package/dist/core/cli/commands/project/logging/show.js.map +1 -1
- package/dist/core/cli/commands/project/modules/add-action.d.ts +17 -0
- package/dist/core/cli/commands/project/modules/add-action.js +240 -0
- package/dist/core/cli/commands/project/modules/add-action.js.map +1 -0
- package/dist/core/cli/commands/project/modules/add.d.ts +1 -15
- package/dist/core/cli/commands/project/modules/add.js +56 -261
- package/dist/core/cli/commands/project/modules/add.js.map +1 -1
- package/dist/core/cli/commands/project/modules/index.js +2 -2
- package/dist/core/cli/commands/project/modules/index.js.map +1 -1
- package/dist/core/cli/commands/project/modules/install-action.d.ts +17 -0
- package/dist/core/cli/commands/project/modules/install-action.js +265 -0
- package/dist/core/cli/commands/project/modules/install-action.js.map +1 -0
- package/dist/core/cli/commands/project/modules/install.d.ts +0 -9
- package/dist/core/cli/commands/project/modules/install.js +54 -240
- package/dist/core/cli/commands/project/modules/install.js.map +1 -1
- package/dist/core/cli/commands/project/modules/list-action.d.ts +8 -0
- package/dist/core/cli/commands/project/modules/list-action.js +85 -0
- package/dist/core/cli/commands/project/modules/list-action.js.map +1 -0
- package/dist/core/cli/commands/project/modules/list.d.ts +2 -1
- package/dist/core/cli/commands/project/modules/list.js +54 -116
- package/dist/core/cli/commands/project/modules/list.js.map +1 -1
- package/dist/core/cli/commands/project/modules/remove-action.d.ts +7 -0
- package/dist/core/cli/commands/project/modules/remove-action.js +81 -0
- package/dist/core/cli/commands/project/modules/remove-action.js.map +1 -0
- package/dist/core/cli/commands/project/modules/remove.d.ts +0 -7
- package/dist/core/cli/commands/project/modules/remove.js +50 -100
- package/dist/core/cli/commands/project/modules/remove.js.map +1 -1
- package/dist/core/cli/commands/project/modules/update-action.d.ts +7 -0
- package/dist/core/cli/commands/project/modules/update-action.js +117 -0
- package/dist/core/cli/commands/project/modules/update-action.js.map +1 -0
- package/dist/core/cli/commands/project/modules/update.js +54 -86
- package/dist/core/cli/commands/project/modules/update.js.map +1 -1
- package/dist/core/cli/commands/project/run.js +2 -2
- package/dist/core/cli/commands/project/run.js.map +1 -1
- package/dist/core/cli/commands/project/start-action.d.ts +8 -0
- package/dist/core/cli/commands/project/start-action.js +47 -0
- package/dist/core/cli/commands/project/start-action.js.map +1 -0
- package/dist/core/cli/commands/project/start.js +53 -55
- package/dist/core/cli/commands/project/start.js.map +1 -1
- package/dist/core/cli/commands/shared/names.d.ts +1 -0
- package/dist/core/cli/commands/shared/names.js +10 -0
- package/dist/core/cli/commands/shared/names.js.map +1 -0
- package/dist/core/cli/commands/shared/next-steps.d.ts +5 -0
- package/dist/core/cli/commands/shared/next-steps.js +26 -0
- package/dist/core/cli/commands/shared/next-steps.js.map +1 -0
- package/dist/core/cli/commands/shared/project-command.d.ts +9 -0
- package/dist/core/cli/commands/shared/project-command.js +79 -14
- package/dist/core/cli/commands/shared/project-command.js.map +1 -1
- package/dist/core/cli/commands/update.js +47 -9
- package/dist/core/cli/commands/update.js.map +1 -1
- package/dist/core/cli/common.d.ts +3 -8
- package/dist/core/cli/common.js +26 -32
- package/dist/core/cli/common.js.map +1 -1
- package/dist/core/cli/exit-codes.d.ts +2 -0
- package/dist/core/cli/exit-codes.js +4 -1
- package/dist/core/cli/exit-codes.js.map +1 -1
- package/dist/core/cli/full-cli.js +62 -41
- package/dist/core/cli/full-cli.js.map +1 -1
- package/dist/core/cli/git-operations.js +10 -17
- package/dist/core/cli/git-operations.js.map +1 -1
- package/dist/core/cli/help.d.ts +8 -0
- package/dist/core/cli/help.js +34 -0
- package/dist/core/cli/help.js.map +1 -0
- package/dist/core/cli/index.js +9 -16
- package/dist/core/cli/index.js.map +1 -1
- package/dist/core/cli/lazy-action.d.ts +4 -0
- package/dist/core/cli/lazy-action.js +10 -0
- package/dist/core/cli/lazy-action.js.map +1 -0
- package/dist/core/cli/logging-utils.js +18 -14
- package/dist/core/cli/logging-utils.js.map +1 -1
- package/dist/core/cli/options.d.ts +20 -0
- package/dist/core/cli/options.js +51 -0
- package/dist/core/cli/options.js.map +1 -0
- package/dist/core/cli/output/boundary.d.ts +7 -0
- package/dist/core/cli/output/boundary.js +78 -0
- package/dist/core/cli/output/boundary.js.map +1 -0
- package/dist/core/cli/output/capabilities.d.ts +10 -0
- package/dist/core/cli/output/capabilities.js +114 -0
- package/dist/core/cli/output/capabilities.js.map +1 -0
- package/dist/core/cli/output/data.d.ts +7 -0
- package/dist/core/cli/output/data.js +11 -0
- package/dist/core/cli/output/data.js.map +1 -0
- package/dist/core/cli/output/errors.d.ts +14 -0
- package/dist/core/cli/output/errors.js +67 -0
- package/dist/core/cli/output/errors.js.map +1 -0
- package/dist/core/cli/output/failures.d.ts +3 -0
- package/dist/core/cli/output/failures.js +97 -0
- package/dist/core/cli/output/failures.js.map +1 -0
- package/dist/core/cli/output/format.d.ts +7 -0
- package/dist/core/cli/output/format.js +64 -0
- package/dist/core/cli/output/format.js.map +1 -0
- package/dist/core/cli/output/index.d.ts +13 -0
- package/dist/core/cli/output/index.js +30 -0
- package/dist/core/cli/output/index.js.map +1 -0
- package/dist/core/cli/output/prompt.d.ts +15 -0
- package/dist/core/cli/output/prompt.js +145 -0
- package/dist/core/cli/output/prompt.js.map +1 -0
- package/dist/core/cli/output/symbols.d.ts +4 -0
- package/dist/core/cli/output/symbols.js +44 -0
- package/dist/core/cli/output/symbols.js.map +1 -0
- package/dist/core/cli/output/tasks.d.ts +57 -0
- package/dist/core/cli/output/tasks.js +310 -0
- package/dist/core/cli/output/tasks.js.map +1 -0
- package/dist/core/cli/output/translations.d.ts +4 -0
- package/dist/core/cli/output/translations.js +109 -0
- package/dist/core/cli/output/translations.js.map +1 -0
- package/dist/core/cli/output/types.d.ts +140 -0
- package/dist/core/cli/output/types.js +3 -0
- package/dist/core/cli/output/types.js.map +1 -0
- package/dist/core/cli/output/ui.d.ts +2 -0
- package/dist/core/cli/output/ui.js +155 -0
- package/dist/core/cli/output/ui.js.map +1 -0
- package/dist/core/cli/output/verbosity.d.ts +8 -0
- package/dist/core/cli/output/verbosity.js +19 -0
- package/dist/core/cli/output/verbosity.js.map +1 -0
- package/dist/core/cli/package-manager.js +2 -2
- package/dist/core/cli/package-manager.js.map +1 -1
- package/dist/core/cli/plugin-arguments.d.ts +5 -0
- package/dist/core/cli/plugin-arguments.js +40 -0
- package/dist/core/cli/plugin-arguments.js.map +1 -0
- package/dist/core/cli/plugin-compatibility.d.ts +5 -2
- package/dist/core/cli/plugin-compatibility.js +22 -15
- package/dist/core/cli/plugin-compatibility.js.map +1 -1
- package/dist/core/cli/plugin-management.d.ts +19 -1
- package/dist/core/cli/plugin-management.js +102 -48
- package/dist/core/cli/plugin-management.js.map +1 -1
- package/dist/core/cli/plugin-registry.d.ts +0 -1
- package/dist/core/cli/plugin-registry.js +2 -3
- package/dist/core/cli/plugin-registry.js.map +1 -1
- package/dist/core/cli/plugin.js +54 -59
- package/dist/core/cli/plugin.js.map +1 -1
- package/dist/core/cli/process-runner.d.ts +2 -0
- package/dist/core/cli/process-runner.js +3 -0
- package/dist/core/cli/process-runner.js.map +1 -1
- package/dist/core/cli/production-start.d.ts +0 -1
- package/dist/core/cli/production-start.js +12 -21
- package/dist/core/cli/production-start.js.map +1 -1
- package/dist/core/cli/public.d.ts +13 -0
- package/dist/core/cli/public.js +42 -0
- package/dist/core/cli/public.js.map +1 -0
- package/dist/core/cli/usage-errors.d.ts +2 -0
- package/dist/core/cli/usage-errors.js +50 -0
- package/dist/core/cli/usage-errors.js.map +1 -0
- package/dist/core/cli/version-check.d.ts +22 -3
- package/dist/core/cli/version-check.js +140 -16
- package/dist/core/cli/version-check.js.map +1 -1
- package/dist/core/config/config-loader.d.ts +2 -1
- package/dist/core/config/config-loader.js +6 -2
- package/dist/core/config/config-loader.js.map +1 -1
- package/dist/core/downloaders/git.js +26 -20
- package/dist/core/downloaders/git.js.map +1 -1
- package/dist/core/downloaders/local.js +0 -1
- package/dist/core/downloaders/local.js.map +1 -1
- package/dist/core/downloaders/package.js +4 -5
- package/dist/core/downloaders/package.js.map +1 -1
- package/dist/core/downloaders/utils.d.ts +3 -1
- package/dist/core/downloaders/utils.js +39 -29
- package/dist/core/downloaders/utils.js.map +1 -1
- package/dist/core/runtime/launch-sequence.js +4 -4
- package/dist/core/runtime/launch-sequence.js.map +1 -1
- package/dist/core/runtime/module-loading.js +43 -36
- package/dist/core/runtime/module-loading.js.map +1 -1
- package/dist/core/version-checker.js +19 -13
- package/dist/core/version-checker.js.map +1 -1
- package/dist/logging/index.js +31 -7
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/log-template.d.ts +8 -0
- package/dist/logging/log-template.js +45 -0
- package/dist/logging/log-template.js.map +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/object.js +12 -0
- package/dist/utils/object.js.map +1 -1
- package/package.json +12 -6
- package/dist/core/cli/terminal-display.d.ts +0 -17
- package/dist/core/cli/terminal-display.js +0 -113
- package/dist/core/cli/terminal-display.js.map +0 -1
|
@@ -1,274 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.projectModulesAddCommand = projectModulesAddCommand;
|
|
36
|
+
exports.MODULE_SOURCE_MODES = void 0;
|
|
8
37
|
exports.default = default_1;
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
12
38
|
const commander_1 = require("commander");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const filesystem_1 = require("../../../../filesystem");
|
|
18
|
-
const common_1 = require("../../../common");
|
|
19
|
-
const git_1 = require("../../../../downloaders/git");
|
|
20
|
-
const registry_1 = require("../../../../downloaders/registry");
|
|
21
|
-
const local_1 = require("../../../../downloaders/local");
|
|
22
|
-
const package_1 = require("../../../../downloaders/package");
|
|
23
|
-
const cli_ui_1 = require("../../../cli-ui");
|
|
24
|
-
const local_folder_1 = require("../../../../downloaders/local-folder");
|
|
25
|
-
const version_checker_1 = require("../../../../version-checker");
|
|
26
|
-
const LOCAL_MODULE_WATCH_DIRS = ["src"];
|
|
27
|
-
const LOCAL_MODULE_BUILD_COMMAND = ["npx tsc"];
|
|
28
|
-
exports.handlers = new Map();
|
|
29
|
-
async function downloadModuleToCache(registry, cache, projectPath, moduleName, moduleConfig) {
|
|
30
|
-
const loaderIdentifier = registry.getLoaderIdentifier(moduleConfig.source);
|
|
31
|
-
if (!loaderIdentifier) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
(0, cli_ui_1.info)(`Downloading module ${chalk_1.default.bold(moduleName)} to cache...`);
|
|
35
|
-
try {
|
|
36
|
-
const moduleManifests = await registry.load(projectPath, cache, {
|
|
37
|
-
...moduleConfig.source,
|
|
38
|
-
id: moduleName,
|
|
39
|
-
});
|
|
40
|
-
if (moduleManifests.length > 0) {
|
|
41
|
-
const manifest = moduleManifests[0];
|
|
42
|
-
if (manifest.manifest.antelopeJs?.defaultConfig) {
|
|
43
|
-
moduleConfig.config = manifest.manifest.antelopeJs.defaultConfig;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
(0, cli_ui_1.success)(`Successfully downloaded module ${chalk_1.default.bold(moduleName)} to cache`);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
51
|
-
(0, cli_ui_1.error)(`Failed to download module ${chalk_1.default.bold(moduleName)}: ${errorMessage}`);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async function displayAddResults(added, skipped, failed) {
|
|
56
|
-
let resultContent = "";
|
|
57
|
-
if (added.length > 0) {
|
|
58
|
-
resultContent += `${chalk_1.default.green.bold("Successfully added:")}\n`;
|
|
59
|
-
added.forEach((name) => {
|
|
60
|
-
resultContent += ` • ${chalk_1.default.bold(name)}\n`;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (skipped.length > 0) {
|
|
64
|
-
if (resultContent)
|
|
65
|
-
resultContent += "\n";
|
|
66
|
-
resultContent += `${chalk_1.default.yellow.bold("Skipped:")}\n`;
|
|
67
|
-
skipped.forEach((name) => {
|
|
68
|
-
resultContent += ` • ${chalk_1.default.dim(name)}\n`;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (failed.length > 0) {
|
|
72
|
-
if (resultContent)
|
|
73
|
-
resultContent += "\n";
|
|
74
|
-
resultContent += `${chalk_1.default.red.bold("Failed:")}\n`;
|
|
75
|
-
failed.forEach((name) => {
|
|
76
|
-
resultContent += ` • ${chalk_1.default.bold(name)}\n`;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
if (resultContent) {
|
|
80
|
-
const borderColor = added.length > 0 ? "green" : failed.length > 0 ? "red" : "yellow";
|
|
81
|
-
await (0, cli_ui_1.displayBox)(resultContent, "📦 Module Addition Results", {
|
|
82
|
-
padding: 1,
|
|
83
|
-
borderColor,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async function projectModulesAddCommand(modules, options) {
|
|
88
|
-
console.log("");
|
|
89
|
-
(0, cli_ui_1.info)(`Adding modules to your project...`);
|
|
90
|
-
const resolvedProjectPath = node_path_1.default.resolve(options.project);
|
|
91
|
-
const envLabel = options.env || "default";
|
|
92
|
-
const config = await (0, common_1.readConfig)(resolvedProjectPath);
|
|
93
|
-
if (!config) {
|
|
94
|
-
(0, cli_ui_1.error)(`No project configuration found at: ${chalk_1.default.bold(resolvedProjectPath)}`);
|
|
95
|
-
(0, cli_ui_1.warning)(`Make sure you're in an AntelopeJS project or use the --project option.`);
|
|
96
|
-
process.exitCode = 1;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const fs = new filesystem_1.NodeFileSystem();
|
|
100
|
-
const loader = new config_1.ConfigLoader(fs);
|
|
101
|
-
const antelopeConfig = await loader.load(resolvedProjectPath, envLabel);
|
|
102
|
-
const registry = new registry_1.DownloaderRegistry();
|
|
103
|
-
(0, local_1.registerLocalDownloader)(registry, { fs, exec: command_1.ExecuteCMD });
|
|
104
|
-
(0, local_folder_1.registerLocalFolderDownloader)(registry, { fs });
|
|
105
|
-
(0, package_1.registerPackageDownloader)(registry, { fs, exec: command_1.ExecuteCMD });
|
|
106
|
-
(0, git_1.registerGitDownloader)(registry, { fs, exec: command_1.ExecuteCMD });
|
|
107
|
-
const failed = [];
|
|
108
|
-
let sources = await Promise.all(modules.map((module) => {
|
|
109
|
-
const modulePath = options.mode === "local" || options.mode === "dir"
|
|
110
|
-
? node_path_1.default.isAbsolute(module)
|
|
111
|
-
? module
|
|
112
|
-
: node_path_1.default.join(resolvedProjectPath, module)
|
|
113
|
-
: module;
|
|
114
|
-
(0, cli_ui_1.info)(`Adding ${chalk_1.default.bold(modulePath)} using ${options.mode} mode`);
|
|
115
|
-
return exports.handlers
|
|
116
|
-
.get(options.mode)?.(module, {
|
|
117
|
-
...options,
|
|
118
|
-
project: resolvedProjectPath,
|
|
119
|
-
})
|
|
120
|
-
.catch((err) => {
|
|
121
|
-
(0, cli_ui_1.error)(err instanceof Error
|
|
122
|
-
? err
|
|
123
|
-
: `Failed to add module "${module}": ${String(err)}`);
|
|
124
|
-
failed.push(module);
|
|
125
|
-
return null;
|
|
126
|
-
});
|
|
127
|
-
}));
|
|
128
|
-
sources = sources.filter((source) => source !== null);
|
|
129
|
-
const env = options.env && options.env !== "default"
|
|
130
|
-
? config?.environments?.[options.env]
|
|
131
|
-
: config;
|
|
132
|
-
if (!env) {
|
|
133
|
-
(0, cli_ui_1.error)(`Environment ${envLabel} not found in project config`);
|
|
134
|
-
process.exitCode = 1;
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (!env.modules) {
|
|
138
|
-
env.modules = {};
|
|
139
|
-
}
|
|
140
|
-
const added = [];
|
|
141
|
-
const skipped = [];
|
|
142
|
-
const cacheFolder = config.cacheFolder ?? ".antelope/cache";
|
|
143
|
-
const cachePath = node_path_1.default.isAbsolute(cacheFolder)
|
|
144
|
-
? cacheFolder
|
|
145
|
-
: node_path_1.default.join(resolvedProjectPath, cacheFolder);
|
|
146
|
-
const cache = new module_cache_1.ModuleCache(cachePath);
|
|
147
|
-
await cache.load();
|
|
148
|
-
const moduleLoadingTasks = sources.map(async (source) => {
|
|
149
|
-
if (!source)
|
|
150
|
-
return null;
|
|
151
|
-
const [moduleName, moduleConfig] = source;
|
|
152
|
-
if (antelopeConfig.modules[moduleName]) {
|
|
153
|
-
return { moduleName, moduleConfig, skipped: true, failed: false };
|
|
154
|
-
}
|
|
155
|
-
const downloadable = typeof moduleConfig === "object" &&
|
|
156
|
-
moduleConfig !== null &&
|
|
157
|
-
"source" in moduleConfig;
|
|
158
|
-
const downloaded = downloadable
|
|
159
|
-
? await downloadModuleToCache(registry, cache, resolvedProjectPath, moduleName, moduleConfig)
|
|
160
|
-
: true;
|
|
161
|
-
return { moduleName, moduleConfig, skipped: false, failed: !downloaded };
|
|
162
|
-
});
|
|
163
|
-
const moduleResults = await Promise.all(moduleLoadingTasks);
|
|
164
|
-
for (const result of moduleResults) {
|
|
165
|
-
if (!result)
|
|
166
|
-
continue;
|
|
167
|
-
const { moduleName, moduleConfig, skipped: wasSkipped, failed: hasFailed, } = result;
|
|
168
|
-
if (hasFailed) {
|
|
169
|
-
failed.push(moduleName);
|
|
170
|
-
}
|
|
171
|
-
else if (wasSkipped) {
|
|
172
|
-
skipped.push(moduleName);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
env.modules[moduleName] = moduleConfig;
|
|
176
|
-
added.push(moduleName);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (failed.length > 0) {
|
|
180
|
-
process.exitCode = 1;
|
|
181
|
-
}
|
|
182
|
-
if (added.length > 0) {
|
|
183
|
-
await (0, common_1.writeConfig)(resolvedProjectPath, config);
|
|
184
|
-
}
|
|
185
|
-
await displayAddResults(added, skipped, failed);
|
|
186
|
-
return { added, skipped, failed };
|
|
187
|
-
}
|
|
39
|
+
const options_1 = require("../../../options");
|
|
40
|
+
const help_1 = require("../../../help");
|
|
41
|
+
const lazy_action_1 = require("../../../lazy-action");
|
|
42
|
+
exports.MODULE_SOURCE_MODES = ["package", "git", "local", "dir"];
|
|
188
43
|
function default_1() {
|
|
189
|
-
|
|
190
|
-
.
|
|
191
|
-
|
|
192
|
-
.argument("<modules...>", "
|
|
193
|
-
.addOption(new commander_1.Option("-m, --mode <mode>", "Source
|
|
194
|
-
.choices(
|
|
44
|
+
const command = new commander_1.Command("add")
|
|
45
|
+
.summary("Add modules to the project")
|
|
46
|
+
.description("Add modules to the project configuration and download them. --mode sets where they come from: package (an npm package, optionally with a version, range or dist-tag), git (a repository URL), local (the folder of one module) or dir (a folder whose every subfolder is a module).")
|
|
47
|
+
.argument("<modules...>", "npm packages, repository URLs or paths, depending on --mode")
|
|
48
|
+
.addOption(new commander_1.Option("-m, --mode <mode>", "Source of the modules")
|
|
49
|
+
.choices(exports.MODULE_SOURCE_MODES)
|
|
195
50
|
.default("package"))
|
|
196
|
-
.addOption(
|
|
197
|
-
.addOption(
|
|
198
|
-
.action(async (
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
exports.handlers.set("package", async (module) => {
|
|
203
|
-
const m = module.match(/^(.+?)(?:@(.*))?$/);
|
|
204
|
-
(0, node_assert_1.default)(m, `Invalid npm module format: '${module}'. Use <name>@<version>, <name>version or <name>`);
|
|
205
|
-
const [, name, version] = m;
|
|
206
|
-
if (version) {
|
|
207
|
-
await (0, version_checker_1.validateVersionSpec)(name, version);
|
|
208
|
-
}
|
|
209
|
-
const resolvedVersion = version
|
|
210
|
-
? version
|
|
211
|
-
: (0, version_checker_1.toFloatingSpec)(await (0, version_checker_1.fetchLatestVersion)(name));
|
|
212
|
-
return [
|
|
213
|
-
name,
|
|
51
|
+
.addOption(options_1.Options.project)
|
|
52
|
+
.addOption(options_1.Options.env)
|
|
53
|
+
.action((0, lazy_action_1.lazyAction)(async () => (await Promise.resolve().then(() => __importStar(require("./add-action")))).projectModulesAddCommand));
|
|
54
|
+
return (0, help_1.withExamples)(command, [
|
|
214
55
|
{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
package: name,
|
|
218
|
-
version: resolvedVersion,
|
|
219
|
-
},
|
|
56
|
+
description: "Add the latest version of an npm package",
|
|
57
|
+
command: "ajs project modules add @antelopejs/api",
|
|
220
58
|
},
|
|
221
|
-
];
|
|
222
|
-
});
|
|
223
|
-
exports.handlers.set("git", async (module) => {
|
|
224
|
-
(0, node_assert_1.default)(module.includes("://") || module.includes("@"), `Invalid git URL format: '${module}'`);
|
|
225
|
-
return [
|
|
226
|
-
node_path_1.default.basename(module, ".git"),
|
|
227
59
|
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
remote: module,
|
|
231
|
-
},
|
|
60
|
+
description: "Pin an exact version",
|
|
61
|
+
command: "ajs project modules add @antelopejs/api@1.3.2",
|
|
232
62
|
},
|
|
233
|
-
];
|
|
234
|
-
});
|
|
235
|
-
exports.handlers.set("local", async (module, options) => {
|
|
236
|
-
const resolvedModulePath = node_path_1.default.isAbsolute(module)
|
|
237
|
-
? node_path_1.default.resolve(module)
|
|
238
|
-
: node_path_1.default.resolve(node_path_1.default.join(options.project, module));
|
|
239
|
-
(0, node_assert_1.default)((await (0, promises_1.stat)(resolvedModulePath)).isDirectory(), `Path '${module}' is not a directory`);
|
|
240
|
-
const packagePath = node_path_1.default.join(resolvedModulePath, "package.json");
|
|
241
|
-
(0, node_assert_1.default)((await (0, promises_1.stat)(packagePath)).isFile(), `No package.json found in '${module}'`);
|
|
242
|
-
const info = JSON.parse((await (0, promises_1.readFile)(packagePath)).toString());
|
|
243
|
-
return [
|
|
244
|
-
info.name,
|
|
245
|
-
{
|
|
246
|
-
source: {
|
|
247
|
-
type: "local",
|
|
248
|
-
path: node_path_1.default.relative(options.project, resolvedModulePath) || ".",
|
|
249
|
-
watchDir: LOCAL_MODULE_WATCH_DIRS,
|
|
250
|
-
installCommand: LOCAL_MODULE_BUILD_COMMAND,
|
|
251
|
-
reloadCommand: LOCAL_MODULE_BUILD_COMMAND,
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
];
|
|
255
|
-
});
|
|
256
|
-
exports.handlers.set("dir", async (module, options) => {
|
|
257
|
-
const resolvedFolderPath = node_path_1.default.isAbsolute(module)
|
|
258
|
-
? node_path_1.default.resolve(module)
|
|
259
|
-
: node_path_1.default.resolve(node_path_1.default.join(options.project, module));
|
|
260
|
-
(0, node_assert_1.default)((await (0, promises_1.stat)(resolvedFolderPath)).isDirectory(), `Path '${module}' is not a directory`);
|
|
261
|
-
return [
|
|
262
|
-
`:${resolvedFolderPath}`,
|
|
263
63
|
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
path: node_path_1.default.relative(options.project, resolvedFolderPath) || ".",
|
|
267
|
-
watchDir: LOCAL_MODULE_WATCH_DIRS,
|
|
268
|
-
installCommand: LOCAL_MODULE_BUILD_COMMAND,
|
|
269
|
-
reloadCommand: LOCAL_MODULE_BUILD_COMMAND,
|
|
270
|
-
},
|
|
64
|
+
description: "Add a module from a local folder",
|
|
65
|
+
command: "ajs project modules add ./modules/auth --mode local",
|
|
271
66
|
},
|
|
272
|
-
];
|
|
273
|
-
}
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
274
69
|
//# sourceMappingURL=add.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../../../src/core/cli/commands/project/modules/add.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../../../src/core/cli/commands/project/modules/add.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,4BAoCC;AA5CD,yCAA4C;AAE5C,8CAA2C;AAC3C,wCAA6C;AAC7C,sDAAkD;AAErC,QAAA,mBAAmB,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEtE;IACE,MAAM,OAAO,GAAG,IAAI,mBAAO,CAAC,KAAK,CAAC;SAC/B,OAAO,CAAC,4BAA4B,CAAC;SACrC,WAAW,CACV,qRAAqR,CACtR;SACA,QAAQ,CACP,cAAc,EACd,6DAA6D,CAC9D;SACA,SAAS,CACR,IAAI,kBAAM,CAAC,mBAAmB,EAAE,uBAAuB,CAAC;SACrD,OAAO,CAAC,2BAAmB,CAAC;SAC5B,OAAO,CAAC,SAAS,CAAC,CACtB;SACA,SAAS,CAAC,iBAAO,CAAC,OAAO,CAAC;SAC1B,SAAS,CAAC,iBAAO,CAAC,GAAG,CAAC;SACtB,MAAM,CACL,IAAA,wBAAU,EACR,KAAK,IAAI,EAAE,CAAC,CAAC,wDAAa,cAAc,GAAC,CAAC,CAAC,wBAAwB,CACpE,CACF,CAAC;IACJ,OAAO,IAAA,mBAAY,EAAC,OAAO,EAAE;QAC3B;YACE,WAAW,EAAE,0CAA0C;YACvD,OAAO,EAAE,yCAAyC;SACnD;QACD;YACE,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE,+CAA+C;SACzD;QACD;YACE,WAAW,EAAE,kCAAkC;YAC/C,OAAO,EAAE,qDAAqD;SAC/D;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -12,8 +12,8 @@ const update_1 = __importDefault(require("./update"));
|
|
|
12
12
|
const install_1 = __importDefault(require("./install"));
|
|
13
13
|
function default_1() {
|
|
14
14
|
return new commander_1.Command("modules")
|
|
15
|
-
.
|
|
16
|
-
|
|
15
|
+
.summary("Add, remove, list and update modules")
|
|
16
|
+
.description("Add, remove, list and update the modules of the project, and add the modules that implement its unresolved interfaces.")
|
|
17
17
|
.addCommand((0, add_1.default)())
|
|
18
18
|
.addCommand((0, remove_1.default)())
|
|
19
19
|
.addCommand((0, update_1.default)())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/core/cli/commands/project/modules/index.ts"],"names":[],"mappings":";;;;;AAQA,4BAWC;AAnBD,yCAAoC;AAEpC,gDAA2B;AAC3B,kDAA6B;AAC7B,sDAAiC;AACjC,sDAAiC;AACjC,wDAAmC;AAEnC;IACE,OAAO,IAAI,mBAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CACV,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/core/cli/commands/project/modules/index.ts"],"names":[],"mappings":";;;;;AAQA,4BAWC;AAnBD,yCAAoC;AAEpC,gDAA2B;AAC3B,kDAA6B;AAC7B,sDAAiC;AACjC,sDAAiC;AACjC,wDAAmC;AAEnC;IACE,OAAO,IAAI,mBAAO,CAAC,SAAS,CAAC;SAC1B,OAAO,CAAC,sCAAsC,CAAC;SAC/C,WAAW,CACV,wHAAwH,CACzH;SACA,UAAU,CAAC,IAAA,aAAM,GAAE,CAAC;SACpB,UAAU,CAAC,IAAA,gBAAS,GAAE,CAAC;SACvB,UAAU,CAAC,IAAA,gBAAS,GAAE,CAAC;SACvB,UAAU,CAAC,IAAA,iBAAU,GAAE,CAAC;SACxB,UAAU,CAAC,IAAA,cAAO,GAAE,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ModuleSource } from "@antelopejs/interface-core/config";
|
|
2
|
+
interface InstallOptions {
|
|
3
|
+
project: string;
|
|
4
|
+
env?: string;
|
|
5
|
+
git?: string;
|
|
6
|
+
yes?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UnresolvedImport {
|
|
9
|
+
interfacePackage: string;
|
|
10
|
+
moduleId: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function describeUnresolvedImport(imp: UnresolvedImport): string;
|
|
14
|
+
export declare function unresolvedImportWarning(imp: UnresolvedImport, git: string): string;
|
|
15
|
+
export declare function resolveInstallIdentifier(source: ModuleSource, identifier: string): string;
|
|
16
|
+
export declare function installModules(options: InstallOptions): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.describeUnresolvedImport = describeUnresolvedImport;
|
|
7
|
+
exports.unresolvedImportWarning = unresolvedImportWarning;
|
|
8
|
+
exports.resolveInstallIdentifier = resolveInstallIdentifier;
|
|
9
|
+
exports.installModules = installModules;
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const command_1 = require("../../../command");
|
|
12
|
+
const add_action_1 = require("./add-action");
|
|
13
|
+
const module_cache_1 = require("../../../../module-cache");
|
|
14
|
+
const filesystem_1 = require("../../../../filesystem");
|
|
15
|
+
const module_manifest_1 = require("../../../../module-manifest");
|
|
16
|
+
const cli_ui_1 = require("../../../cli-ui");
|
|
17
|
+
const git_1 = require("../../../../downloaders/git");
|
|
18
|
+
const config_1 = require("../../../../config");
|
|
19
|
+
const registry_1 = require("../../../../downloaders/registry");
|
|
20
|
+
const local_1 = require("../../../../downloaders/local");
|
|
21
|
+
const package_1 = require("../../../../downloaders/package");
|
|
22
|
+
const local_folder_1 = require("../../../../downloaders/local-folder");
|
|
23
|
+
const interface_resolution_1 = require("../../../../resolution/interface-resolution");
|
|
24
|
+
const git_operations_1 = require("../../../git-operations");
|
|
25
|
+
const output_1 = require("../../../output");
|
|
26
|
+
const config_paths_1 = require("../../../../config/config-paths");
|
|
27
|
+
const common_1 = require("../../../common");
|
|
28
|
+
const next_steps_1 = require("../../shared/next-steps");
|
|
29
|
+
const project_command_1 = require("../../shared/project-command");
|
|
30
|
+
function describeUnresolvedImport(imp) {
|
|
31
|
+
const version = imp.version ? `@${imp.version}` : "";
|
|
32
|
+
return `${imp.interfacePackage}${version} (required by ${imp.moduleId})`;
|
|
33
|
+
}
|
|
34
|
+
function unresolvedImportWarning(imp, git) {
|
|
35
|
+
return `${describeUnresolvedImport(imp)}: no module found implementing it in repository ${git}`;
|
|
36
|
+
}
|
|
37
|
+
const PACKAGE_SOURCE_TYPE = "package";
|
|
38
|
+
const INSTALL_COMMAND = "ajs project modules install";
|
|
39
|
+
const YES_FLAG = "--yes";
|
|
40
|
+
const DEFAULT_ENVIRONMENT = "default";
|
|
41
|
+
const DEFAULT_CACHE_FOLDER = ".antelope/cache";
|
|
42
|
+
const GROUP_KEY_SEPARATOR = ":";
|
|
43
|
+
const DEV_COMMAND = "ajs project dev";
|
|
44
|
+
const DEV_DESCRIPTION = "run the project with its new modules";
|
|
45
|
+
async function chooseImplementation(prompter, interfaceName, candidates) {
|
|
46
|
+
const [firstCandidate] = candidates;
|
|
47
|
+
if (candidates.length === 1) {
|
|
48
|
+
(0, cli_ui_1.info)(`${(0, output_1.getProcessPalette)().bold(firstCandidate.name)} is the only module implementing ${interfaceName}: selected automatically`);
|
|
49
|
+
return firstCandidate;
|
|
50
|
+
}
|
|
51
|
+
return prompter.select({
|
|
52
|
+
message: `Select a module to add for ${interfaceName}:`,
|
|
53
|
+
flag: YES_FLAG,
|
|
54
|
+
defaultAnswer: firstCandidate,
|
|
55
|
+
choices: candidates.map((candidate) => ({
|
|
56
|
+
value: candidate,
|
|
57
|
+
label: candidate.name,
|
|
58
|
+
})),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function resolveInstallIdentifier(source, identifier) {
|
|
62
|
+
if (source.type !== PACKAGE_SOURCE_TYPE) {
|
|
63
|
+
return identifier;
|
|
64
|
+
}
|
|
65
|
+
const version = source.version;
|
|
66
|
+
return version ? `${identifier}@${version}` : identifier;
|
|
67
|
+
}
|
|
68
|
+
async function analyzeConfig(projectFolder, cache, config, registry, fs) {
|
|
69
|
+
const manifests = (await Promise.all(Object.entries(config.modules).map(([name, module]) => registry.load(projectFolder, cache, {
|
|
70
|
+
...module.source,
|
|
71
|
+
id: name,
|
|
72
|
+
})))).flat();
|
|
73
|
+
try {
|
|
74
|
+
const coreRoot = node_path_1.default.resolve(__dirname, "../../../../../..");
|
|
75
|
+
const coreManifest = await module_manifest_1.ModuleManifest.create(coreRoot, { type: "local", path: coreRoot, id: "antelopejs" }, "antelopejs", fs);
|
|
76
|
+
manifests.push(coreManifest);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
}
|
|
80
|
+
const providers = manifests.map((m) => ({
|
|
81
|
+
name: m.manifest.name,
|
|
82
|
+
implements: m.implements ?? [],
|
|
83
|
+
}));
|
|
84
|
+
const consumers = manifests.map((m) => ({
|
|
85
|
+
id: m.name,
|
|
86
|
+
folder: m.folder,
|
|
87
|
+
dependencies: m.manifest.dependencies ?? {},
|
|
88
|
+
optionalDependencies: m.manifest.optionalDependencies ?? {},
|
|
89
|
+
}));
|
|
90
|
+
const requiredVersions = new Map(consumers.map((consumer) => [
|
|
91
|
+
consumer.id,
|
|
92
|
+
{ ...consumer.dependencies, ...consumer.optionalDependencies },
|
|
93
|
+
]));
|
|
94
|
+
const { unresolved } = (0, interface_resolution_1.findUnresolvedInterfaces)(providers, consumers);
|
|
95
|
+
return {
|
|
96
|
+
unresolvedImports: unresolved.map((u) => ({
|
|
97
|
+
interfacePackage: u.interfacePackage,
|
|
98
|
+
moduleId: u.moduleId,
|
|
99
|
+
version: requiredVersions.get(u.moduleId)?.[u.interfacePackage],
|
|
100
|
+
})),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function createRegistry(fs) {
|
|
104
|
+
const registry = new registry_1.DownloaderRegistry();
|
|
105
|
+
(0, local_1.registerLocalDownloader)(registry, { fs, exec: command_1.ExecuteCMD });
|
|
106
|
+
(0, local_folder_1.registerLocalFolderDownloader)(registry, { fs });
|
|
107
|
+
(0, package_1.registerPackageDownloader)(registry, { fs, exec: command_1.ExecuteCMD });
|
|
108
|
+
(0, git_1.registerGitDownloader)(registry, { fs, exec: command_1.ExecuteCMD });
|
|
109
|
+
return registry;
|
|
110
|
+
}
|
|
111
|
+
async function createInstallContext(options, baseConfig) {
|
|
112
|
+
const git = options.git || (await (0, common_1.readUserConfig)()).git;
|
|
113
|
+
(0, common_1.displayNonDefaultGitWarning)(git);
|
|
114
|
+
const gitManifest = await (0, git_operations_1.loadManifestFromGit)(git);
|
|
115
|
+
const fs = new filesystem_1.NodeFileSystem();
|
|
116
|
+
const cacheFolder = baseConfig.cacheFolder ?? DEFAULT_CACHE_FOLDER;
|
|
117
|
+
const cache = new module_cache_1.ModuleCache(node_path_1.default.resolve(options.project, cacheFolder));
|
|
118
|
+
await cache.load();
|
|
119
|
+
return {
|
|
120
|
+
options,
|
|
121
|
+
prompter: (0, output_1.createPrompter)({
|
|
122
|
+
command: INSTALL_COMMAND,
|
|
123
|
+
acceptsDefaults: options.yes,
|
|
124
|
+
defaultsFlag: YES_FLAG,
|
|
125
|
+
}),
|
|
126
|
+
git,
|
|
127
|
+
gitManifest,
|
|
128
|
+
fs,
|
|
129
|
+
loader: new config_1.ConfigLoader(fs),
|
|
130
|
+
registry: createRegistry(fs),
|
|
131
|
+
cache,
|
|
132
|
+
modulesToInstall: [],
|
|
133
|
+
unresolvedImportCount: 0,
|
|
134
|
+
unimplementedImportCount: 0,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function environmentsToAnalyze(options, baseConfig, environment) {
|
|
138
|
+
if (options.env) {
|
|
139
|
+
return [environment];
|
|
140
|
+
}
|
|
141
|
+
return baseConfig.environments
|
|
142
|
+
? Object.keys(baseConfig.environments)
|
|
143
|
+
: [DEFAULT_ENVIRONMENT];
|
|
144
|
+
}
|
|
145
|
+
async function analyzeEnvironment(context, env) {
|
|
146
|
+
const { options, cache, registry, fs } = context;
|
|
147
|
+
const config = await context.loader.load(options.project, env);
|
|
148
|
+
try {
|
|
149
|
+
const analysis = await (0, output_1.runTask)(`Analyzing environment ${env}`, () => analyzeConfig(options.project, cache, config, registry, fs), { done: `Analyzed environment ${env}` });
|
|
150
|
+
return analysis.unresolvedImports;
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
const cause = (0, output_1.describeFailure)(err, false);
|
|
154
|
+
throw new output_1.CliError({
|
|
155
|
+
title: `Could not analyze environment ${env}`,
|
|
156
|
+
reason: cause.title,
|
|
157
|
+
fixes: cause.fixes,
|
|
158
|
+
}, { cause: err });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function findImplementations(context, interfaceName) {
|
|
162
|
+
const interfaceDirName = context.gitManifest.interfaces[interfaceName];
|
|
163
|
+
if (!interfaceDirName) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
const interfaceInfo = await (0, git_operations_1.loadInterfaceFromGit)(context.git, interfaceDirName);
|
|
167
|
+
return interfaceInfo?.manifest.modules ?? [];
|
|
168
|
+
}
|
|
169
|
+
async function selectImplementation(context, env, imp) {
|
|
170
|
+
const interfaceName = imp.interfacePackage;
|
|
171
|
+
const candidates = await findImplementations(context, interfaceName);
|
|
172
|
+
const names = candidates.map((candidate) => candidate.name);
|
|
173
|
+
const selected = context.modulesToInstall.find((module) => names.includes(module.moduleName));
|
|
174
|
+
if (selected) {
|
|
175
|
+
selected.imports.push(interfaceName);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (candidates.length === 0) {
|
|
179
|
+
(0, cli_ui_1.warning)(unresolvedImportWarning(imp, context.git));
|
|
180
|
+
context.unimplementedImportCount += 1;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const chosen = await chooseImplementation(context.prompter, interfaceName, candidates);
|
|
184
|
+
const loaderIdentifier = context.registry.getLoaderIdentifier(chosen.source);
|
|
185
|
+
if (!loaderIdentifier) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
context.modulesToInstall.push({
|
|
189
|
+
loaderIdentifier: resolveInstallIdentifier(chosen.source, loaderIdentifier),
|
|
190
|
+
mode: chosen.source.type,
|
|
191
|
+
moduleName: chosen.name,
|
|
192
|
+
imports: [interfaceName],
|
|
193
|
+
env,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
async function resolveEnvironment(context, env) {
|
|
197
|
+
const unresolvedImports = await analyzeEnvironment(context, env);
|
|
198
|
+
if (unresolvedImports.length === 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
context.unresolvedImportCount += unresolvedImports.length;
|
|
202
|
+
(0, output_1.getProcessUi)().message("warn", `${(0, output_1.pluralize)(unresolvedImports.length, "unresolved import")} in ${env}:`, { details: unresolvedImports.map(describeUnresolvedImport) });
|
|
203
|
+
for (const imp of unresolvedImports) {
|
|
204
|
+
await selectImplementation(context, env, imp);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function groupByEnvironmentAndMode(modules) {
|
|
208
|
+
const groups = new Map();
|
|
209
|
+
modules.forEach((module) => {
|
|
210
|
+
const key = [module.env, module.mode].join(GROUP_KEY_SEPARATOR);
|
|
211
|
+
groups.set(key, [...(groups.get(key) ?? []), module]);
|
|
212
|
+
});
|
|
213
|
+
return groups;
|
|
214
|
+
}
|
|
215
|
+
async function installSelectedModules(context) {
|
|
216
|
+
const results = [];
|
|
217
|
+
const groups = groupByEnvironmentAndMode(context.modulesToInstall);
|
|
218
|
+
for (const modules of groups.values()) {
|
|
219
|
+
const [{ env, mode }] = modules;
|
|
220
|
+
results.push(await (0, add_action_1.addModules)(modules.map((module) => module.loaderIdentifier), { mode, project: context.options.project, env }));
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
added: results.reduce((sum, result) => sum + result.added.length, 0),
|
|
224
|
+
failed: results.reduce((sum, result) => sum + result.failed.length, 0),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function installHeadline(context, outcome) {
|
|
228
|
+
if (context.unresolvedImportCount === 0) {
|
|
229
|
+
return "All interfaces are implemented";
|
|
230
|
+
}
|
|
231
|
+
const parts = [
|
|
232
|
+
`${(0, output_1.pluralize)(outcome.added, "module")} added to ${config_paths_1.TS_CONFIG_FILE}`,
|
|
233
|
+
outcome.failed > 0 ? `${outcome.failed} failed` : "",
|
|
234
|
+
context.unimplementedImportCount > 0
|
|
235
|
+
? `${(0, output_1.pluralize)(context.unimplementedImportCount, "import")} still unresolved`
|
|
236
|
+
: "",
|
|
237
|
+
];
|
|
238
|
+
return parts.filter((part) => part !== "").join(", ");
|
|
239
|
+
}
|
|
240
|
+
function installNextSteps(context, outcome) {
|
|
241
|
+
if (outcome.added === 0) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
return [
|
|
245
|
+
{
|
|
246
|
+
command: (0, next_steps_1.scopedCommand)(DEV_COMMAND, context.options),
|
|
247
|
+
description: DEV_DESCRIPTION,
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
async function installModules(options) {
|
|
252
|
+
const startedAt = Date.now();
|
|
253
|
+
const { config: baseConfig, environment } = await (0, project_command_1.resolveProjectContext)(options.project, options.env);
|
|
254
|
+
const context = await createInstallContext(options, baseConfig);
|
|
255
|
+
for (const env of environmentsToAnalyze(options, baseConfig, environment)) {
|
|
256
|
+
await resolveEnvironment(context, env);
|
|
257
|
+
}
|
|
258
|
+
const outcome = await installSelectedModules(context);
|
|
259
|
+
(0, output_1.getProcessUi)().summary({
|
|
260
|
+
headline: installHeadline(context, outcome),
|
|
261
|
+
durationMs: Date.now() - startedAt,
|
|
262
|
+
nextSteps: installNextSteps(context, outcome),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=install-action.js.map
|