@powerlines/nx 0.11.294 → 0.11.296
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/dist/src/_virtual/_rolldown/runtime.js +29 -0
- package/dist/src/base/base-executor.d.mts +28 -2
- package/dist/src/base/base-executor.d.mts.map +1 -0
- package/dist/src/base/base-executor.d.ts +28 -2
- package/dist/src/base/base-executor.d.ts.map +1 -0
- package/dist/src/base/base-executor.js +3 -3
- package/dist/src/base/base-executor.untyped.d.mts +7 -2
- package/dist/src/base/base-executor.untyped.d.mts.map +1 -0
- package/dist/src/base/base-executor.untyped.d.ts +6 -2
- package/dist/src/base/base-executor.untyped.d.ts.map +1 -0
- package/dist/src/base/base-executor.untyped.js +1 -1
- package/dist/src/base/index.d.mts +1 -1
- package/dist/src/base/index.d.ts +1 -1
- package/dist/src/base-executor-BOTlYnaD.d.mts +163 -0
- package/dist/src/base-executor-BOTlYnaD.d.mts.map +1 -0
- package/dist/src/base-executor-DH33Fd1U.js +79 -0
- package/dist/src/base-executor-N_ZgvzpA.d.ts +163 -0
- package/dist/src/base-executor-N_ZgvzpA.d.ts.map +1 -0
- package/dist/src/base-executor-dn4QVqZ4.mjs +72 -0
- package/dist/src/base-executor-dn4QVqZ4.mjs.map +1 -0
- package/dist/src/base-executor.untyped-CWwiE6fo.mjs +162 -0
- package/dist/src/base-executor.untyped-CWwiE6fo.mjs.map +1 -0
- package/dist/src/base-executor.untyped-DwcuTgJP.js +167 -0
- package/dist/src/executors/build/executor.d.mts +2 -2
- package/dist/src/executors/build/executor.d.ts +1 -1
- package/dist/src/executors/build/executor.js +2 -2
- package/dist/src/executors/build/executor.mjs +1 -1
- package/dist/src/executors/build/untyped.js +1 -0
- package/dist/src/executors/build/untyped.mjs +1 -0
- package/dist/src/executors/build/untyped.mjs.map +1 -1
- package/dist/src/executors/clean/executor.d.mts +2 -2
- package/dist/src/executors/clean/executor.d.ts +1 -1
- package/dist/src/executors/clean/executor.js +2 -2
- package/dist/src/executors/clean/executor.mjs +1 -1
- package/dist/src/executors/clean/untyped.js +2 -2
- package/dist/src/executors/clean/untyped.mjs +1 -1
- package/dist/src/executors/docs/executor.d.mts +2 -2
- package/dist/src/executors/docs/executor.d.ts +1 -1
- package/dist/src/executors/docs/executor.js +2 -2
- package/dist/src/executors/docs/executor.mjs +1 -1
- package/dist/src/executors/docs/untyped.js +1 -0
- package/dist/src/executors/docs/untyped.mjs +1 -0
- package/dist/src/executors/docs/untyped.mjs.map +1 -1
- package/dist/src/executors/lint/executor.d.mts +2 -2
- package/dist/src/executors/lint/executor.d.ts +1 -1
- package/dist/src/executors/lint/executor.js +2 -2
- package/dist/src/executors/lint/executor.mjs +1 -1
- package/dist/src/executors/lint/untyped.js +1 -0
- package/dist/src/executors/lint/untyped.mjs +1 -0
- package/dist/src/executors/lint/untyped.mjs.map +1 -1
- package/dist/src/executors/prepare/executor.d.mts +2 -2
- package/dist/src/executors/prepare/executor.d.ts +1 -1
- package/dist/src/executors/prepare/executor.js +2 -2
- package/dist/src/executors/prepare/executor.mjs +1 -1
- package/dist/src/executors/prepare/untyped.js +2 -2
- package/dist/src/executors/prepare/untyped.mjs +1 -1
- package/dist/src/helpers/constants.d.mts +8 -2
- package/dist/src/helpers/constants.d.mts.map +1 -0
- package/dist/src/helpers/constants.d.ts +8 -2
- package/dist/src/helpers/constants.d.ts.map +1 -0
- package/dist/src/helpers/index.d.mts +2 -2
- package/dist/src/helpers/index.d.ts +2 -2
- package/dist/src/helpers/plugin-utilities.d.mts +57 -2
- package/dist/src/helpers/plugin-utilities.d.mts.map +1 -0
- package/dist/src/helpers/plugin-utilities.d.ts +57 -2
- package/dist/src/helpers/plugin-utilities.d.ts.map +1 -0
- package/dist/src/helpers/plugin-utilities.js +2 -2
- package/dist/src/helpers/plugin-utilities.mjs +2 -2
- package/dist/src/helpers/plugin-utilities.mjs.map +1 -1
- package/dist/src/index.d.mts +4 -4
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +0 -1
- package/dist/src/index.mjs +0 -1
- package/dist/src/plugin/index.d.mts +241 -1
- package/dist/src/plugin/index.d.mts.map +1 -1
- package/dist/src/plugin/index.d.ts +241 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +296 -2
- package/dist/src/plugin/index.mjs +293 -1
- package/dist/src/plugin/index.mjs.map +1 -1
- package/dist/src/types/index.d.mts +1 -1
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/plugin.d.mts +243 -2
- package/dist/src/types/plugin.d.mts.map +1 -0
- package/dist/src/types/plugin.d.ts +243 -2
- package/dist/src/types/plugin.d.ts.map +1 -0
- package/package.json +13 -13
- package/dist/src/base-executor-Bj63x9OE.d.ts +0 -28
- package/dist/src/base-executor-Bj63x9OE.d.ts.map +0 -1
- package/dist/src/base-executor-D6POztG2.d.mts +0 -28
- package/dist/src/base-executor-D6POztG2.d.mts.map +0 -1
- package/dist/src/base-executor.untyped-D4R6pki2.d.ts +0 -7
- package/dist/src/base-executor.untyped-D4R6pki2.d.ts.map +0 -1
- package/dist/src/base-executor.untyped-hmlG6oyC.d.mts +0 -7
- package/dist/src/base-executor.untyped-hmlG6oyC.d.mts.map +0 -1
- package/dist/src/constants-CbG11Mby.d.ts +0 -8
- package/dist/src/constants-CbG11Mby.d.ts.map +0 -1
- package/dist/src/constants-VDvVnoLC.d.mts +0 -8
- package/dist/src/constants-VDvVnoLC.d.mts.map +0 -1
- package/dist/src/plugin-B_ZGdX7U.d.mts +0 -243
- package/dist/src/plugin-B_ZGdX7U.d.mts.map +0 -1
- package/dist/src/plugin-DpyutMl2.d.ts +0 -243
- package/dist/src/plugin-DpyutMl2.d.ts.map +0 -1
- package/dist/src/plugin-utilities-Cg-Ccp4C.d.mts +0 -57
- package/dist/src/plugin-utilities-Cg-Ccp4C.d.mts.map +0 -1
- package/dist/src/plugin-utilities-CmfuC3TZ.d.ts +0 -57
- package/dist/src/plugin-utilities-CmfuC3TZ.d.ts.map +0 -1
package/dist/src/plugin/index.js
CHANGED
|
@@ -1,8 +1,302 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
3
|
+
let _nx_devkit = require("@nx/devkit");
|
|
4
|
+
let _storm_software_workspace_tools_utils_nx_json = require("@storm-software/workspace-tools/utils/nx-json");
|
|
5
|
+
let _storm_software_workspace_tools_utils_plugin_helpers = require("@storm-software/workspace-tools/utils/plugin-helpers");
|
|
6
|
+
let _storm_software_workspace_tools_utils_project_tags = require("@storm-software/workspace-tools/utils/project-tags");
|
|
7
|
+
let _stryke_env_get_env_paths = require("@stryke/env/get-env-paths");
|
|
8
|
+
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
9
|
+
let _stryke_hash = require("@stryke/hash");
|
|
10
|
+
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
11
|
+
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
12
|
+
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
13
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
14
|
+
let _stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
|
|
15
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
16
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
17
|
+
let defu = require("defu");
|
|
18
|
+
defu = require_chunk.__toESM(defu);
|
|
19
|
+
let jiti = require("jiti");
|
|
20
|
+
let node_fs_promises = require("node:fs/promises");
|
|
21
|
+
let nx_src_config_nx_json_js = require("nx/src/config/nx-json.js");
|
|
22
|
+
let nx_src_utils_package_json_js = require("nx/src/utils/package-json.js");
|
|
23
|
+
let powerlines_config = require("powerlines/config");
|
|
24
|
+
let powerlines_constants = require("powerlines/constants");
|
|
3
25
|
|
|
26
|
+
//#region src/helpers/constants.ts
|
|
27
|
+
/**
|
|
28
|
+
* A list of Nx input strings that describe the Powerlines configuration file
|
|
29
|
+
*/
|
|
30
|
+
const CONFIG_INPUTS = [
|
|
31
|
+
"{projectRoot}/{framework}.json",
|
|
32
|
+
"{projectRoot}/{framework}.*.json",
|
|
33
|
+
"{projectRoot}/{framework}.jsonc",
|
|
34
|
+
"{projectRoot}/{framework}.*.jsonc",
|
|
35
|
+
"{projectRoot}/{framework}.json5",
|
|
36
|
+
"{projectRoot}/{framework}.*.json5",
|
|
37
|
+
"{projectRoot}/{framework}.yaml",
|
|
38
|
+
"{projectRoot}/{framework}.*.yaml",
|
|
39
|
+
"{projectRoot}/{framework}.yml",
|
|
40
|
+
"{projectRoot}/{framework}.*.yml",
|
|
41
|
+
"{projectRoot}/{framework}.toml",
|
|
42
|
+
"{projectRoot}/{framework}.*.toml",
|
|
43
|
+
"{projectRoot}/{framework}.config.js",
|
|
44
|
+
"{projectRoot}/{framework}.*.config.js",
|
|
45
|
+
"{projectRoot}/{framework}.config.cjs",
|
|
46
|
+
"{projectRoot}/{framework}.*.config.cjs",
|
|
47
|
+
"{projectRoot}/{framework}.config.mjs",
|
|
48
|
+
"{projectRoot}/{framework}.*.config.mjs",
|
|
49
|
+
"{projectRoot}/{framework}.config.ts",
|
|
50
|
+
"{projectRoot}/{framework}.*.config.ts",
|
|
51
|
+
"{projectRoot}/{framework}.config.cts",
|
|
52
|
+
"{projectRoot}/{framework}.*.config.cts",
|
|
53
|
+
"{projectRoot}/{framework}.config.mts",
|
|
54
|
+
"{projectRoot}/{framework}.*.config.mts"
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/helpers/plugin-utilities.ts
|
|
59
|
+
/**
|
|
60
|
+
* Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
|
|
61
|
+
*
|
|
62
|
+
* @param framework - The framework name to use in the input strings
|
|
63
|
+
* @returns An array of Nx input strings for the configuration file
|
|
64
|
+
*/
|
|
65
|
+
function getNxTargetInputs(framework) {
|
|
66
|
+
return CONFIG_INPUTS.map((input) => input.replace("{framework}", framework));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
|
|
70
|
+
*
|
|
71
|
+
* @param framework - The framework name to use in the input strings
|
|
72
|
+
* @returns An array of Nx input strings for the configuration file
|
|
73
|
+
*/
|
|
74
|
+
function getNxPluginInputs(framework) {
|
|
75
|
+
return `**/{${getNxTargetInputs(framework).map((input) => input.replace("{projectRoot}/", "")).join(",")}}`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates an Nx plugin that integrates Powerlines into the Nx build process.
|
|
79
|
+
*
|
|
80
|
+
* @param opts - Options for creating the Nx plugin
|
|
81
|
+
* @returns A CreateNodesV2 function that can be used as an Nx plugin
|
|
82
|
+
*/
|
|
83
|
+
function createNxPlugin(opts) {
|
|
84
|
+
const framework = opts?.framework || "powerlines";
|
|
85
|
+
const title = `${(0, _stryke_string_format_title_case.titleCase)(framework)} Nx Plugin`;
|
|
86
|
+
try {
|
|
87
|
+
const name = opts?.name || `${framework}/nx/plugin`;
|
|
88
|
+
const artifactsFolder = opts?.artifactsFolder || `{projectRoot}/.${framework}`;
|
|
89
|
+
const targetInputs = getNxTargetInputs(framework);
|
|
90
|
+
const pluginInputs = getNxPluginInputs(framework);
|
|
91
|
+
return [pluginInputs, async (configFiles, options, contextV2) => {
|
|
92
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the ${title} for the following inputs: ${pluginInputs}`);
|
|
93
|
+
const envPaths = (0, _stryke_env_get_env_paths.getEnvPaths)({
|
|
94
|
+
orgId: "storm-software",
|
|
95
|
+
appId: framework,
|
|
96
|
+
workspaceRoot: contextV2.workspaceRoot
|
|
97
|
+
});
|
|
98
|
+
if (!envPaths.cache) throw new Error("The cache directory could not be determined.");
|
|
99
|
+
const nxJson = (0, nx_src_config_nx_json_js.readNxJson)(contextV2.workspaceRoot);
|
|
100
|
+
const resolver = (0, jiti.createJiti)(contextV2.workspaceRoot, {
|
|
101
|
+
debug: !!options?.debug,
|
|
102
|
+
interopDefault: true,
|
|
103
|
+
fsCache: (0, _stryke_path_join_paths.joinPaths)(envPaths.cache, "nx-plugin", (0, _stryke_hash.murmurhash)(contextV2.workspaceRoot, { maxLength: powerlines_constants.ROOT_HASH_LENGTH }), "jiti"),
|
|
104
|
+
moduleCache: true
|
|
105
|
+
});
|
|
106
|
+
return (0, _nx_devkit.createNodesFromFiles)(async (configFile, _, context) => {
|
|
107
|
+
try {
|
|
108
|
+
const projectRoot = (0, _storm_software_workspace_tools_utils_plugin_helpers.getProjectRoot)(configFile, contextV2.workspaceRoot);
|
|
109
|
+
if (!projectRoot) {
|
|
110
|
+
console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - package.json and ${framework} configuration files (i.e. ${framework}.config.ts) must be located in the project root directory: ${configFile}`);
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
const root = (0, _storm_software_workspace_tools_utils_plugin_helpers.getRoot)(projectRoot, context);
|
|
114
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Loading ${framework} user configuration for project in root directory ${projectRoot}.`);
|
|
115
|
+
let userConfig = {};
|
|
116
|
+
try {
|
|
117
|
+
userConfig = await (0, powerlines_config.loadUserConfigFile)(projectRoot, contextV2.workspaceRoot, resolver, "build", "development", configFile, framework);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Failed to load user configuration for project in ${projectRoot} - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "Unknown error"} \n\nThis error can occur if the project depends on another package in the workspace and the dependent package has not been built yet. To resolve this issue, please ensure that all dependent packages have been built successfully.`);
|
|
120
|
+
}
|
|
121
|
+
if (!(0, _stryke_fs_exists.existsSync)((0, _stryke_path_join_paths.joinPaths)(contextV2.workspaceRoot, projectRoot, "package.json"))) {
|
|
122
|
+
if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Cannot find \`package.json\` file in the project's root directory (path: "${(0, _stryke_path_join_paths.joinPaths)(contextV2.workspaceRoot, projectRoot)}"). Skipping project configuration.`);
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
const packageJsonContent = await (0, node_fs_promises.readFile)((0, _stryke_path_join_paths.joinPaths)(contextV2.workspaceRoot, projectRoot, "package.json"), "utf8");
|
|
126
|
+
if (!packageJsonContent) {
|
|
127
|
+
if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No package.json file found for project in root directory ${projectRoot}`);
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
131
|
+
if (!userConfig.configFile && !packageJson?.[(0, _stryke_string_format_camel_case.camelCase)(framework)]) {
|
|
132
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Skipping ${projectRoot} - no ${framework} configuration found for project in root directory.`);
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
const projectConfig = (0, _storm_software_workspace_tools_utils_plugin_helpers.getProjectConfigFromProjectRoot)(projectRoot, packageJson);
|
|
136
|
+
if (!projectConfig) {
|
|
137
|
+
if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No project configuration found for project in root directory ${projectRoot}`);
|
|
138
|
+
return {};
|
|
139
|
+
}
|
|
140
|
+
const targets = (0, nx_src_utils_package_json_js.readTargetsFromPackageJson)(packageJson, nxJson, projectRoot, context.workspaceRoot);
|
|
141
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
|
|
142
|
+
if (options?.clean !== false && !targets[options?.clean?.targetName || "clean"]) targets[options?.clean?.targetName || "clean"] = {
|
|
143
|
+
cache: true,
|
|
144
|
+
inputs: Array.isArray(options?.clean?.inputs) ? options.clean.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)(targetInputs, [options?.clean?.inputs || "typescript"]),
|
|
145
|
+
outputs: options?.clean?.outputs,
|
|
146
|
+
executor: options?.clean?.executor || `@${framework}/nx:${options?.clean?.targetName || "clean"}`,
|
|
147
|
+
dependsOn: options?.clean?.dependsOn ?? [`^${options?.clean?.targetName || "clean"}`],
|
|
148
|
+
defaultConfiguration: options?.clean?.defaultConfiguration || "production",
|
|
149
|
+
options: {
|
|
150
|
+
projectType: projectConfig.projectType,
|
|
151
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
152
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
153
|
+
},
|
|
154
|
+
configurations: {
|
|
155
|
+
production: { mode: "production" },
|
|
156
|
+
test: { mode: "test" },
|
|
157
|
+
development: {
|
|
158
|
+
mode: "development",
|
|
159
|
+
skipCache: true
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
if (options?.prepare !== false && !targets[options?.prepare?.targetName || "prepare"]) targets[options?.prepare?.targetName || "prepare"] = {
|
|
164
|
+
cache: true,
|
|
165
|
+
inputs: Array.isArray(options?.prepare?.inputs) ? options.prepare.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)(targetInputs, [options?.prepare?.inputs || "typescript"]),
|
|
166
|
+
outputs: options?.prepare?.outputs ?? [artifactsFolder],
|
|
167
|
+
executor: options?.prepare?.executor || `@${framework}/nx:${options?.prepare?.targetName || "prepare"}`,
|
|
168
|
+
dependsOn: options?.prepare?.dependsOn ?? [`^${options?.prepare?.targetName || "build"}`, options?.clean !== false && `${options?.clean?.targetName || "clean"}`].filter(Boolean),
|
|
169
|
+
defaultConfiguration: options?.prepare?.defaultConfiguration || "production",
|
|
170
|
+
options: {
|
|
171
|
+
projectType: projectConfig.projectType,
|
|
172
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
173
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
174
|
+
},
|
|
175
|
+
configurations: {
|
|
176
|
+
production: { mode: "production" },
|
|
177
|
+
test: { mode: "test" },
|
|
178
|
+
development: {
|
|
179
|
+
mode: "development",
|
|
180
|
+
skipCache: true
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
if (options?.build !== false && !targets[options?.build?.targetName || "build"]) targets[options?.build?.targetName || "build"] = {
|
|
185
|
+
cache: true,
|
|
186
|
+
inputs: Array.isArray(options?.build?.inputs) ? options.build.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)(targetInputs, [options?.build?.inputs || "typescript"]),
|
|
187
|
+
outputs: options?.build?.outputs ?? ["{options.outputPath}"],
|
|
188
|
+
executor: options?.build?.executor || `@${framework}/nx:${options?.build?.targetName || "build"}`,
|
|
189
|
+
dependsOn: options?.build?.dependsOn ?? [`^${options?.build?.targetName || "build"}`, userConfig.skipCache ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
|
|
190
|
+
defaultConfiguration: options?.build?.defaultConfiguration || "production",
|
|
191
|
+
options: {
|
|
192
|
+
projectType: projectConfig.projectType,
|
|
193
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
194
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
195
|
+
},
|
|
196
|
+
configurations: {
|
|
197
|
+
production: { mode: "production" },
|
|
198
|
+
test: { mode: "test" },
|
|
199
|
+
development: {
|
|
200
|
+
mode: "development",
|
|
201
|
+
skipCache: true
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
if (options?.lint !== false && !targets[options?.lint?.targetName || "lint"]) targets[options?.lint?.targetName || "lint"] = {
|
|
206
|
+
cache: true,
|
|
207
|
+
inputs: Array.isArray(options?.lint?.inputs) ? options.lint.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)([...targetInputs, artifactsFolder], options?.lint?.inputs ? [options.lint.inputs] : ["linting", "typescript"]),
|
|
208
|
+
outputs: options?.lint?.outputs ?? ["{options.outputPath}"],
|
|
209
|
+
executor: options?.lint?.executor || `@${framework}/nx:${options?.lint?.targetName || "lint"}`,
|
|
210
|
+
dependsOn: options?.lint?.dependsOn ?? [`^${options?.lint?.targetName || "lint"}`, userConfig.skipCache ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
|
|
211
|
+
defaultConfiguration: options?.lint?.defaultConfiguration || "production",
|
|
212
|
+
options: {
|
|
213
|
+
projectType: projectConfig.projectType,
|
|
214
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
215
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
216
|
+
},
|
|
217
|
+
configurations: {
|
|
218
|
+
production: { mode: "production" },
|
|
219
|
+
test: { mode: "test" },
|
|
220
|
+
development: {
|
|
221
|
+
mode: "development",
|
|
222
|
+
skipCache: true
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
if (options?.docs !== false && !targets[options?.docs?.targetName || "docs"]) targets[options?.docs?.targetName || "docs"] = {
|
|
227
|
+
cache: true,
|
|
228
|
+
inputs: Array.isArray(options?.docs?.inputs) ? options.docs.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)([...targetInputs, artifactsFolder], options?.docs?.inputs ? [options.docs.inputs] : ["documentation", "typescript"]),
|
|
229
|
+
outputs: options?.docs?.outputs ?? ["{options.outputPath}"],
|
|
230
|
+
executor: options?.docs?.executor || `@${framework}/nx:${options?.docs?.targetName || "docs"}`,
|
|
231
|
+
dependsOn: options?.docs?.dependsOn ?? [
|
|
232
|
+
`^${options?.docs?.targetName || "docs"}`,
|
|
233
|
+
options?.build !== false && `${options?.build?.targetName || "build"}`,
|
|
234
|
+
userConfig.skipCache ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
|
|
235
|
+
].filter(Boolean),
|
|
236
|
+
defaultConfiguration: options?.docs?.defaultConfiguration || "production",
|
|
237
|
+
options: {
|
|
238
|
+
projectType: projectConfig.projectType,
|
|
239
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
240
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
241
|
+
},
|
|
242
|
+
configurations: {
|
|
243
|
+
production: { mode: "production" },
|
|
244
|
+
test: { mode: "test" },
|
|
245
|
+
development: {
|
|
246
|
+
mode: "development",
|
|
247
|
+
skipCache: true
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
if (options?.deploy !== false && !targets[options?.deploy?.targetName || "deploy"]) targets[options?.deploy?.targetName || "deploy"] = {
|
|
252
|
+
inputs: Array.isArray(options?.deploy?.inputs) ? options.deploy.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)([...targetInputs, artifactsFolder], options?.deploy?.inputs ? [options.deploy.inputs] : ["documentation", "typescript"]),
|
|
253
|
+
outputs: options?.deploy?.outputs ?? ["{options.outputPath}"],
|
|
254
|
+
executor: options?.deploy?.executor || `@${framework}/nx:${options?.deploy?.targetName || "deploy"}`,
|
|
255
|
+
dependsOn: options?.deploy?.dependsOn ?? [
|
|
256
|
+
`^${options?.deploy?.targetName || "deploy"}`,
|
|
257
|
+
options?.build !== false && `${options?.build?.targetName || "build"}`,
|
|
258
|
+
userConfig.skipCache ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
|
|
259
|
+
].filter(Boolean),
|
|
260
|
+
defaultConfiguration: options?.deploy?.defaultConfiguration || "production",
|
|
261
|
+
options: {
|
|
262
|
+
projectType: projectConfig.projectType,
|
|
263
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
264
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
265
|
+
},
|
|
266
|
+
configurations: {
|
|
267
|
+
production: { mode: "production" },
|
|
268
|
+
test: { mode: "test" },
|
|
269
|
+
development: {
|
|
270
|
+
mode: "development",
|
|
271
|
+
skipCache: true
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
(0, _storm_software_workspace_tools_utils_project_tags.setDefaultProjectTags)(projectConfig, name);
|
|
276
|
+
(0, _storm_software_workspace_tools_utils_project_tags.addProjectTag)(projectConfig, framework, projectConfig.projectType || "library", { overwrite: true });
|
|
277
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
|
|
278
|
+
return { projects: { [root]: (0, defu.default)(projectConfig, {
|
|
279
|
+
name: (0, _stryke_string_format_kebab_case.kebabCase)(userConfig.name),
|
|
280
|
+
projectType: projectConfig.projectType || "library",
|
|
281
|
+
root,
|
|
282
|
+
sourceRoot: (0, _stryke_path_join_paths.joinPaths)(root, "src"),
|
|
283
|
+
targets
|
|
284
|
+
}) } };
|
|
285
|
+
} catch (error) {
|
|
286
|
+
console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Failed to process the project configuration for file "${configFile}" - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "Unknown fatal error"}`);
|
|
287
|
+
return {};
|
|
288
|
+
}
|
|
289
|
+
}, configFiles, options, contextV2);
|
|
290
|
+
}];
|
|
291
|
+
} catch (error) {
|
|
292
|
+
console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "Unknown fatal error during plugin initialization"}`);
|
|
293
|
+
throw new Error(`Failed to initialize the ${title} - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "See previous logs for more details"}`, { cause: error instanceof Error ? error : void 0 });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
4
298
|
//#region src/plugin/index.ts
|
|
5
|
-
const createNodesV2 =
|
|
299
|
+
const createNodesV2 = createNxPlugin({ framework: "powerlines" });
|
|
6
300
|
|
|
7
301
|
//#endregion
|
|
8
302
|
exports.createNodesV2 = createNodesV2;
|
|
@@ -1,5 +1,297 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createNodesFromFiles } from "@nx/devkit";
|
|
2
|
+
import { withNamedInputs } from "@storm-software/workspace-tools/utils/nx-json";
|
|
3
|
+
import { getProjectConfigFromProjectRoot, getProjectRoot, getRoot } from "@storm-software/workspace-tools/utils/plugin-helpers";
|
|
4
|
+
import { addProjectTag, setDefaultProjectTags } from "@storm-software/workspace-tools/utils/project-tags";
|
|
5
|
+
import { getEnvPaths } from "@stryke/env/get-env-paths";
|
|
6
|
+
import { existsSync } from "@stryke/fs/exists";
|
|
7
|
+
import { murmurhash } from "@stryke/hash";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
9
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
10
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
11
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
12
|
+
import { isError } from "@stryke/type-checks/is-error";
|
|
13
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
14
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
15
|
+
import defu from "defu";
|
|
16
|
+
import { createJiti } from "jiti";
|
|
17
|
+
import { readFile } from "node:fs/promises";
|
|
18
|
+
import { readNxJson as readNxJson$1 } from "nx/src/config/nx-json.js";
|
|
19
|
+
import { readTargetsFromPackageJson } from "nx/src/utils/package-json.js";
|
|
20
|
+
import { loadUserConfigFile } from "powerlines/config";
|
|
21
|
+
import { ROOT_HASH_LENGTH } from "powerlines/constants";
|
|
2
22
|
|
|
23
|
+
//#region src/helpers/constants.ts
|
|
24
|
+
/**
|
|
25
|
+
* A list of Nx input strings that describe the Powerlines configuration file
|
|
26
|
+
*/
|
|
27
|
+
const CONFIG_INPUTS = [
|
|
28
|
+
"{projectRoot}/{framework}.json",
|
|
29
|
+
"{projectRoot}/{framework}.*.json",
|
|
30
|
+
"{projectRoot}/{framework}.jsonc",
|
|
31
|
+
"{projectRoot}/{framework}.*.jsonc",
|
|
32
|
+
"{projectRoot}/{framework}.json5",
|
|
33
|
+
"{projectRoot}/{framework}.*.json5",
|
|
34
|
+
"{projectRoot}/{framework}.yaml",
|
|
35
|
+
"{projectRoot}/{framework}.*.yaml",
|
|
36
|
+
"{projectRoot}/{framework}.yml",
|
|
37
|
+
"{projectRoot}/{framework}.*.yml",
|
|
38
|
+
"{projectRoot}/{framework}.toml",
|
|
39
|
+
"{projectRoot}/{framework}.*.toml",
|
|
40
|
+
"{projectRoot}/{framework}.config.js",
|
|
41
|
+
"{projectRoot}/{framework}.*.config.js",
|
|
42
|
+
"{projectRoot}/{framework}.config.cjs",
|
|
43
|
+
"{projectRoot}/{framework}.*.config.cjs",
|
|
44
|
+
"{projectRoot}/{framework}.config.mjs",
|
|
45
|
+
"{projectRoot}/{framework}.*.config.mjs",
|
|
46
|
+
"{projectRoot}/{framework}.config.ts",
|
|
47
|
+
"{projectRoot}/{framework}.*.config.ts",
|
|
48
|
+
"{projectRoot}/{framework}.config.cts",
|
|
49
|
+
"{projectRoot}/{framework}.*.config.cts",
|
|
50
|
+
"{projectRoot}/{framework}.config.mts",
|
|
51
|
+
"{projectRoot}/{framework}.*.config.mts"
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/helpers/plugin-utilities.ts
|
|
56
|
+
/**
|
|
57
|
+
* Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
|
|
58
|
+
*
|
|
59
|
+
* @param framework - The framework name to use in the input strings
|
|
60
|
+
* @returns An array of Nx input strings for the configuration file
|
|
61
|
+
*/
|
|
62
|
+
function getNxTargetInputs(framework) {
|
|
63
|
+
return CONFIG_INPUTS.map((input) => input.replace("{framework}", framework));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
|
|
67
|
+
*
|
|
68
|
+
* @param framework - The framework name to use in the input strings
|
|
69
|
+
* @returns An array of Nx input strings for the configuration file
|
|
70
|
+
*/
|
|
71
|
+
function getNxPluginInputs(framework) {
|
|
72
|
+
return `**/{${getNxTargetInputs(framework).map((input) => input.replace("{projectRoot}/", "")).join(",")}}`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates an Nx plugin that integrates Powerlines into the Nx build process.
|
|
76
|
+
*
|
|
77
|
+
* @param opts - Options for creating the Nx plugin
|
|
78
|
+
* @returns A CreateNodesV2 function that can be used as an Nx plugin
|
|
79
|
+
*/
|
|
80
|
+
function createNxPlugin(opts) {
|
|
81
|
+
const framework = opts?.framework || "powerlines";
|
|
82
|
+
const title = `${titleCase(framework)} Nx Plugin`;
|
|
83
|
+
try {
|
|
84
|
+
const name = opts?.name || `${framework}/nx/plugin`;
|
|
85
|
+
const artifactsFolder = opts?.artifactsFolder || `{projectRoot}/.${framework}`;
|
|
86
|
+
const targetInputs = getNxTargetInputs(framework);
|
|
87
|
+
const pluginInputs = getNxPluginInputs(framework);
|
|
88
|
+
return [pluginInputs, async (configFiles, options, contextV2) => {
|
|
89
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the ${title} for the following inputs: ${pluginInputs}`);
|
|
90
|
+
const envPaths = getEnvPaths({
|
|
91
|
+
orgId: "storm-software",
|
|
92
|
+
appId: framework,
|
|
93
|
+
workspaceRoot: contextV2.workspaceRoot
|
|
94
|
+
});
|
|
95
|
+
if (!envPaths.cache) throw new Error("The cache directory could not be determined.");
|
|
96
|
+
const nxJson = readNxJson$1(contextV2.workspaceRoot);
|
|
97
|
+
const resolver = createJiti(contextV2.workspaceRoot, {
|
|
98
|
+
debug: !!options?.debug,
|
|
99
|
+
interopDefault: true,
|
|
100
|
+
fsCache: joinPaths(envPaths.cache, "nx-plugin", murmurhash(contextV2.workspaceRoot, { maxLength: ROOT_HASH_LENGTH }), "jiti"),
|
|
101
|
+
moduleCache: true
|
|
102
|
+
});
|
|
103
|
+
return createNodesFromFiles(async (configFile, _, context) => {
|
|
104
|
+
try {
|
|
105
|
+
const projectRoot = getProjectRoot(configFile, contextV2.workspaceRoot);
|
|
106
|
+
if (!projectRoot) {
|
|
107
|
+
console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - package.json and ${framework} configuration files (i.e. ${framework}.config.ts) must be located in the project root directory: ${configFile}`);
|
|
108
|
+
return {};
|
|
109
|
+
}
|
|
110
|
+
const root = getRoot(projectRoot, context);
|
|
111
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Loading ${framework} user configuration for project in root directory ${projectRoot}.`);
|
|
112
|
+
let userConfig = {};
|
|
113
|
+
try {
|
|
114
|
+
userConfig = await loadUserConfigFile(projectRoot, contextV2.workspaceRoot, resolver, "build", "development", configFile, framework);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Failed to load user configuration for project in ${projectRoot} - ${isError(error) ? error.message : isSetString(error) ? error : "Unknown error"} \n\nThis error can occur if the project depends on another package in the workspace and the dependent package has not been built yet. To resolve this issue, please ensure that all dependent packages have been built successfully.`);
|
|
117
|
+
}
|
|
118
|
+
if (!existsSync(joinPaths(contextV2.workspaceRoot, projectRoot, "package.json"))) {
|
|
119
|
+
if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Cannot find \`package.json\` file in the project's root directory (path: "${joinPaths(contextV2.workspaceRoot, projectRoot)}"). Skipping project configuration.`);
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
const packageJsonContent = await readFile(joinPaths(contextV2.workspaceRoot, projectRoot, "package.json"), "utf8");
|
|
123
|
+
if (!packageJsonContent) {
|
|
124
|
+
if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No package.json file found for project in root directory ${projectRoot}`);
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
128
|
+
if (!userConfig.configFile && !packageJson?.[camelCase(framework)]) {
|
|
129
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Skipping ${projectRoot} - no ${framework} configuration found for project in root directory.`);
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
const projectConfig = getProjectConfigFromProjectRoot(projectRoot, packageJson);
|
|
133
|
+
if (!projectConfig) {
|
|
134
|
+
if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No project configuration found for project in root directory ${projectRoot}`);
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
const targets = readTargetsFromPackageJson(packageJson, nxJson, projectRoot, context.workspaceRoot);
|
|
138
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
|
|
139
|
+
if (options?.clean !== false && !targets[options?.clean?.targetName || "clean"]) targets[options?.clean?.targetName || "clean"] = {
|
|
140
|
+
cache: true,
|
|
141
|
+
inputs: Array.isArray(options?.clean?.inputs) ? options.clean.inputs : withNamedInputs(targetInputs, [options?.clean?.inputs || "typescript"]),
|
|
142
|
+
outputs: options?.clean?.outputs,
|
|
143
|
+
executor: options?.clean?.executor || `@${framework}/nx:${options?.clean?.targetName || "clean"}`,
|
|
144
|
+
dependsOn: options?.clean?.dependsOn ?? [`^${options?.clean?.targetName || "clean"}`],
|
|
145
|
+
defaultConfiguration: options?.clean?.defaultConfiguration || "production",
|
|
146
|
+
options: {
|
|
147
|
+
projectType: projectConfig.projectType,
|
|
148
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
149
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
150
|
+
},
|
|
151
|
+
configurations: {
|
|
152
|
+
production: { mode: "production" },
|
|
153
|
+
test: { mode: "test" },
|
|
154
|
+
development: {
|
|
155
|
+
mode: "development",
|
|
156
|
+
skipCache: true
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
if (options?.prepare !== false && !targets[options?.prepare?.targetName || "prepare"]) targets[options?.prepare?.targetName || "prepare"] = {
|
|
161
|
+
cache: true,
|
|
162
|
+
inputs: Array.isArray(options?.prepare?.inputs) ? options.prepare.inputs : withNamedInputs(targetInputs, [options?.prepare?.inputs || "typescript"]),
|
|
163
|
+
outputs: options?.prepare?.outputs ?? [artifactsFolder],
|
|
164
|
+
executor: options?.prepare?.executor || `@${framework}/nx:${options?.prepare?.targetName || "prepare"}`,
|
|
165
|
+
dependsOn: options?.prepare?.dependsOn ?? [`^${options?.prepare?.targetName || "build"}`, options?.clean !== false && `${options?.clean?.targetName || "clean"}`].filter(Boolean),
|
|
166
|
+
defaultConfiguration: options?.prepare?.defaultConfiguration || "production",
|
|
167
|
+
options: {
|
|
168
|
+
projectType: projectConfig.projectType,
|
|
169
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
170
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
171
|
+
},
|
|
172
|
+
configurations: {
|
|
173
|
+
production: { mode: "production" },
|
|
174
|
+
test: { mode: "test" },
|
|
175
|
+
development: {
|
|
176
|
+
mode: "development",
|
|
177
|
+
skipCache: true
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
if (options?.build !== false && !targets[options?.build?.targetName || "build"]) targets[options?.build?.targetName || "build"] = {
|
|
182
|
+
cache: true,
|
|
183
|
+
inputs: Array.isArray(options?.build?.inputs) ? options.build.inputs : withNamedInputs(targetInputs, [options?.build?.inputs || "typescript"]),
|
|
184
|
+
outputs: options?.build?.outputs ?? ["{options.outputPath}"],
|
|
185
|
+
executor: options?.build?.executor || `@${framework}/nx:${options?.build?.targetName || "build"}`,
|
|
186
|
+
dependsOn: options?.build?.dependsOn ?? [`^${options?.build?.targetName || "build"}`, userConfig.skipCache ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
|
|
187
|
+
defaultConfiguration: options?.build?.defaultConfiguration || "production",
|
|
188
|
+
options: {
|
|
189
|
+
projectType: projectConfig.projectType,
|
|
190
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
191
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
192
|
+
},
|
|
193
|
+
configurations: {
|
|
194
|
+
production: { mode: "production" },
|
|
195
|
+
test: { mode: "test" },
|
|
196
|
+
development: {
|
|
197
|
+
mode: "development",
|
|
198
|
+
skipCache: true
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
if (options?.lint !== false && !targets[options?.lint?.targetName || "lint"]) targets[options?.lint?.targetName || "lint"] = {
|
|
203
|
+
cache: true,
|
|
204
|
+
inputs: Array.isArray(options?.lint?.inputs) ? options.lint.inputs : withNamedInputs([...targetInputs, artifactsFolder], options?.lint?.inputs ? [options.lint.inputs] : ["linting", "typescript"]),
|
|
205
|
+
outputs: options?.lint?.outputs ?? ["{options.outputPath}"],
|
|
206
|
+
executor: options?.lint?.executor || `@${framework}/nx:${options?.lint?.targetName || "lint"}`,
|
|
207
|
+
dependsOn: options?.lint?.dependsOn ?? [`^${options?.lint?.targetName || "lint"}`, userConfig.skipCache ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
|
|
208
|
+
defaultConfiguration: options?.lint?.defaultConfiguration || "production",
|
|
209
|
+
options: {
|
|
210
|
+
projectType: projectConfig.projectType,
|
|
211
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
212
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
213
|
+
},
|
|
214
|
+
configurations: {
|
|
215
|
+
production: { mode: "production" },
|
|
216
|
+
test: { mode: "test" },
|
|
217
|
+
development: {
|
|
218
|
+
mode: "development",
|
|
219
|
+
skipCache: true
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
if (options?.docs !== false && !targets[options?.docs?.targetName || "docs"]) targets[options?.docs?.targetName || "docs"] = {
|
|
224
|
+
cache: true,
|
|
225
|
+
inputs: Array.isArray(options?.docs?.inputs) ? options.docs.inputs : withNamedInputs([...targetInputs, artifactsFolder], options?.docs?.inputs ? [options.docs.inputs] : ["documentation", "typescript"]),
|
|
226
|
+
outputs: options?.docs?.outputs ?? ["{options.outputPath}"],
|
|
227
|
+
executor: options?.docs?.executor || `@${framework}/nx:${options?.docs?.targetName || "docs"}`,
|
|
228
|
+
dependsOn: options?.docs?.dependsOn ?? [
|
|
229
|
+
`^${options?.docs?.targetName || "docs"}`,
|
|
230
|
+
options?.build !== false && `${options?.build?.targetName || "build"}`,
|
|
231
|
+
userConfig.skipCache ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
|
|
232
|
+
].filter(Boolean),
|
|
233
|
+
defaultConfiguration: options?.docs?.defaultConfiguration || "production",
|
|
234
|
+
options: {
|
|
235
|
+
projectType: projectConfig.projectType,
|
|
236
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
237
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
238
|
+
},
|
|
239
|
+
configurations: {
|
|
240
|
+
production: { mode: "production" },
|
|
241
|
+
test: { mode: "test" },
|
|
242
|
+
development: {
|
|
243
|
+
mode: "development",
|
|
244
|
+
skipCache: true
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
if (options?.deploy !== false && !targets[options?.deploy?.targetName || "deploy"]) targets[options?.deploy?.targetName || "deploy"] = {
|
|
249
|
+
inputs: Array.isArray(options?.deploy?.inputs) ? options.deploy.inputs : withNamedInputs([...targetInputs, artifactsFolder], options?.deploy?.inputs ? [options.deploy.inputs] : ["documentation", "typescript"]),
|
|
250
|
+
outputs: options?.deploy?.outputs ?? ["{options.outputPath}"],
|
|
251
|
+
executor: options?.deploy?.executor || `@${framework}/nx:${options?.deploy?.targetName || "deploy"}`,
|
|
252
|
+
dependsOn: options?.deploy?.dependsOn ?? [
|
|
253
|
+
`^${options?.deploy?.targetName || "deploy"}`,
|
|
254
|
+
options?.build !== false && `${options?.build?.targetName || "build"}`,
|
|
255
|
+
userConfig.skipCache ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
|
|
256
|
+
].filter(Boolean),
|
|
257
|
+
defaultConfiguration: options?.deploy?.defaultConfiguration || "production",
|
|
258
|
+
options: {
|
|
259
|
+
projectType: projectConfig.projectType,
|
|
260
|
+
outputPath: `{workspaceRoot}/${projectRoot}/dist`,
|
|
261
|
+
copyPath: `{workspaceRoot}/dist/${projectRoot}`
|
|
262
|
+
},
|
|
263
|
+
configurations: {
|
|
264
|
+
production: { mode: "production" },
|
|
265
|
+
test: { mode: "test" },
|
|
266
|
+
development: {
|
|
267
|
+
mode: "development",
|
|
268
|
+
skipCache: true
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
setDefaultProjectTags(projectConfig, name);
|
|
273
|
+
addProjectTag(projectConfig, framework, projectConfig.projectType || "library", { overwrite: true });
|
|
274
|
+
if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
|
|
275
|
+
return { projects: { [root]: defu(projectConfig, {
|
|
276
|
+
name: kebabCase(userConfig.name),
|
|
277
|
+
projectType: projectConfig.projectType || "library",
|
|
278
|
+
root,
|
|
279
|
+
sourceRoot: joinPaths(root, "src"),
|
|
280
|
+
targets
|
|
281
|
+
}) } };
|
|
282
|
+
} catch (error) {
|
|
283
|
+
console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Failed to process the project configuration for file "${configFile}" - ${isError(error) ? error.message : isSetString(error) ? error : "Unknown fatal error"}`);
|
|
284
|
+
return {};
|
|
285
|
+
}
|
|
286
|
+
}, configFiles, options, contextV2);
|
|
287
|
+
}];
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - ${isError(error) ? error.message : isSetString(error) ? error : "Unknown fatal error during plugin initialization"}`);
|
|
290
|
+
throw new Error(`Failed to initialize the ${title} - ${isError(error) ? error.message : isSetString(error) ? error : "See previous logs for more details"}`, { cause: error instanceof Error ? error : void 0 });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
//#endregion
|
|
3
295
|
//#region src/plugin/index.ts
|
|
4
296
|
const createNodesV2 = createNxPlugin({ framework: "powerlines" });
|
|
5
297
|
|