@toolsplus/nx-forge 4.0.0 → 4.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolsplus/nx-forge",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Atlassian Forge plugin for Nx",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const node_fs_1 = require("node:fs");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const normalize_options_1 = require("./lib/normalize-options");
7
- const process_custom_ui_dependencies_1 = require("./lib/process-custom-ui-dependencies");
7
+ const process_resource_dependencies_1 = require("./lib/process-resource-dependencies");
8
8
  const patch_manifest_yml_1 = require("./lib/patch-manifest-yml");
9
9
  const generate_package_json_1 = require("./lib/generate-package-json");
10
10
  const compile_webpack_1 = require("./lib/compile-webpack");
@@ -49,9 +49,9 @@ function runExecutor(rawOptions, context) {
49
49
  }
50
50
  }
51
51
  (0, copy_forge_app_assets_1.copyForgeAppAssets)(options);
52
- const customUIResources = yield (0, process_custom_ui_dependencies_1.processCustomUIDependencies)(options, context);
53
- yield (0, patch_manifest_yml_1.patchManifestYml)(options);
54
- (0, generate_package_json_1.generatePackageJson)(context.projectName, context.projectGraph, customUIResources, options);
52
+ const resources = yield (0, process_resource_dependencies_1.processResourceDependencies)(Object.assign(Object.assign({}, options), { resourcePath: options.customUIPath }), context);
53
+ yield (0, patch_manifest_yml_1.patchManifestYml)(Object.assign(Object.assign({}, options), { resourcePath: options.customUIPath }));
54
+ (0, generate_package_json_1.generatePackageJson)(context.projectName, context.projectGraph, resources, options);
55
55
  devkit_1.logger.info('Executor ran for build');
56
56
  return {
57
57
  success: true,
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/executors/build/executor.ts"],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,CAC9D,CAAC;oBACJ,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;QAED,IAAA,0CAAkB,EAAC,OAAO,CAAC,CAAC;QAC5B,MAAM,iBAAiB,GAAG,MAAM,IAAA,4DAA2B,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9E,MAAM,IAAA,qCAAgB,EAAC,OAAO,CAAC,CAAC;QAChC,IAAA,2CAAmB,EACjB,OAAO,CAAC,WAAY,EACpB,OAAO,CAAC,YAAa,EACrB,iBAAiB,EACjB,OAAO,CACR,CAAC;QAEF,eAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;;CACH;AA1CD,8BA0CC"}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/executors/build/executor.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAE7C,uCAAoC;AAEpC,+DAA2D;AAC3D,uFAAkF;AAClF,iEAA4D;AAC5D,uEAAkE;AAClE,2DAAuD;AACvD,uEAAiE;AAEjE,SAAS,UAAU,CAAC,IAAc;IAChC,IAAI,CAAC;QACH,OAAO,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAA8B,WAAW,CACvC,UAAgC,EAChC,OAAwB;;;QAExB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GACxB,OAAO,CAAC,sBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC;QAEjE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,WAAW,8BAA8B,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,WAAW,wBAAwB,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAC,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAE7E,IAAI,UAAU,CAAC,GAAG,OAAO,CAAC,WAAW,eAAe,CAAC,EAAE,CAAC;YACtD,MAAM,WAAW,GAAG,IAAA,gCAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;;gBACrD,KAA2B,eAAA,gBAAA,sBAAA,WAAW,CAAA,iBAAA,2FAAE,CAAC;oBAAd,2BAAW;oBAAX,WAAW;oBAA3B,MAAM,MAAM,KAAA,CAAA;oBACrB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACpB,MAAM,IAAI,KAAK,CACb,uCAAuC,OAAO,CAAC,WAAW,GAAG,CAC9D,CAAC;oBACJ,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;QAED,IAAA,0CAAkB,EAAC,OAAO,CAAC,CAAC;QAE5B,MAAM,SAAS,GAAG,MAAM,IAAA,2DAA2B,kCAC5C,OAAO,KAAE,YAAY,EAAE,OAAO,CAAC,YAAY,KAChD,OAAO,CACR,CAAC;QACF,MAAM,IAAA,qCAAgB,kCAAM,OAAO,KAAE,YAAY,EAAE,OAAO,CAAC,YAAY,IAAG,CAAC;QAC3E,IAAA,2CAAmB,EACjB,OAAO,CAAC,WAAY,EACpB,OAAO,CAAC,YAAa,EACrB,SAAS,EACT,OAAO,CACR,CAAC;QAEF,eAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;;CACH;AA9CD,8BA8CC"}
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
4
  function normalizeOptions(options, root, sourceRoot, projectRoot) {
5
- var _a, _b;
5
+ var _a, _b, _c;
6
6
  return Object.assign(Object.assign({}, options), { root,
7
7
  sourceRoot,
8
- projectRoot, customUIPath: (_a = options.customUIPath) !== null && _a !== void 0 ? _a : 'customUI', outputFileName: 'index.js', watch: (_b = options.watch) !== null && _b !== void 0 ? _b : false });
8
+ projectRoot, customUIPath: (_a = options.customUIPath) !== null && _a !== void 0 ? _a : 'customUI', resourceOutputPathMap: (_b = options.resourceOutputPathMap) !== null && _b !== void 0 ? _b : {}, outputFileName: 'index.js', watch: (_c = options.watch) !== null && _c !== void 0 ? _c : false });
9
9
  }
10
10
  exports.normalizeOptions = normalizeOptions;
11
11
  //# sourceMappingURL=normalize-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/build/lib/normalize-options.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAC9B,OAA6B,EAC7B,IAAY,EACZ,UAAkB,EAClB,WAAmB;;IAEnB,uCACK,OAAO,KACV,IAAI;QACJ,UAAU;QACV,WAAW,EACX,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,UAAU,EAChD,cAAc,EAAE,UAAU,EAC1B,KAAK,EAAE,MAAA,OAAO,CAAC,KAAK,mCAAI,KAAK,IAC7B;AACJ,CAAC;AAfD,4CAeC"}
1
+ {"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/build/lib/normalize-options.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAC9B,OAA6B,EAC7B,IAAY,EACZ,UAAkB,EAClB,WAAmB;;IAEnB,uCACK,OAAO,KACV,IAAI;QACJ,UAAU;QACV,WAAW,EACX,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,UAAU,EAChD,qBAAqB,EAAE,MAAA,OAAO,CAAC,qBAAqB,mCAAI,EAAE,EAC1D,cAAc,EAAE,UAAU,EAC1B,KAAK,EAAE,MAAA,OAAO,CAAC,KAAK,mCAAI,KAAK,IAC7B;AACJ,CAAC;AAhBD,4CAgBC"}
@@ -1,10 +1,12 @@
1
1
  import { NormalizedOptions } from '../schema';
2
- type Options = Pick<NormalizedOptions, 'root' | 'outputPath' | 'customUIPath'>;
2
+ type Options = Pick<NormalizedOptions, 'root' | 'outputPath' | 'uiKit2Packaging'> & {
3
+ resourcePath: string;
4
+ };
3
5
  /**
4
- * Patches the output manifest.yml file to replace resource path parameters to point to the actual Custom UI build
6
+ * Patches the output manifest.yml file to replace resource path parameters to point to the actual resource build
5
7
  * artifacts instead of the Nx project reference.
6
8
  *
7
- * This assumes that Custom UI artifacts have already been copied to the output directory in a previous step.
9
+ * This assumes that resource artifacts have already been copied to the output directory in a previous step.
8
10
  *
9
11
  * @param options Executor options
10
12
  */
@@ -5,27 +5,130 @@ const tslib_1 = require("tslib");
5
5
  const path_1 = require("path");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const manifest_yml_1 = require("../../../utils/forge/manifest-yml");
8
+ const fs_1 = require("fs");
8
9
  /**
9
- * Patches the output manifest.yml file to replace resource path parameters to point to the actual Custom UI build
10
+ * Patches the output manifest.yml file to replace resource path parameters to point to the actual resource build
10
11
  * artifacts instead of the Nx project reference.
11
12
  *
12
- * This assumes that Custom UI artifacts have already been copied to the output directory in a previous step.
13
+ * This assumes that resource artifacts have already been copied to the output directory in a previous step.
13
14
  *
14
15
  * @param options Executor options
15
16
  */
16
17
  function patchManifestYml(options) {
17
18
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
- const manifestPath = (0, devkit_1.joinPathFragments)((0, path_1.resolve)(options.root, options.outputPath), 'manifest.yml');
19
+ const absoluteOutputPath = (0, path_1.resolve)(options.root, options.outputPath);
20
+ const manifestPath = (0, devkit_1.joinPathFragments)(absoluteOutputPath, 'manifest.yml');
19
21
  devkit_1.logger.info(`Patching ${manifestPath}...`);
20
22
  const manifestSchema = yield (0, manifest_yml_1.readManifestYml)(manifestPath);
21
- const resources = manifestSchema.resources || [];
22
- const patchedManifest = Object.assign(Object.assign({}, manifestSchema), { resources: resources.map((r) => patchResource(options.customUIPath, r)) });
23
+ const patchedManifest = patchManifestInternal(absoluteOutputPath, manifestSchema, options);
23
24
  (0, manifest_yml_1.writeManifestYml)(manifestPath, patchedManifest);
24
25
  devkit_1.logger.info(`Done patching ${manifestPath}.`);
25
26
  });
26
27
  }
27
28
  exports.patchManifestYml = patchManifestYml;
28
- function patchResource(customUIPath, resource) {
29
- return Object.assign(Object.assign({}, resource), { path: `${customUIPath}/${resource.path}` });
29
+ function patchManifestInternal(absoluteOutputPath, manifestSchema, options) {
30
+ var _a;
31
+ const resources = manifestSchema.resources || [];
32
+ if (!options.uiKit2Packaging) {
33
+ return Object.assign(Object.assign({}, manifestSchema), { resources: resources.map((resource) => (Object.assign(Object.assign({}, resource), { path: `${options.resourcePath}/${resource.path}` }))) });
34
+ }
35
+ else {
36
+ const resourceTypeIndex = getResourceTypeIndex((_a = manifestSchema.modules) !== null && _a !== void 0 ? _a : {}, resources);
37
+ return Object.assign(Object.assign({}, manifestSchema), { resources: resources.map((r) => patchResource(options.resourcePath, r, absoluteOutputPath, resourceTypeIndex[r.key])) });
38
+ }
39
+ }
40
+ /**
41
+ * Computes an index from resource key to resource type which is either UI Kit 2 or Custom UI. The resource type
42
+ * is inferred from the module declaration. If a module has both the `resource` property and `render: native` declared,
43
+ * it means its resource has to be of type UI Kit 2. If a module, on the other hand, only declares the `resource`
44
+ * property, it means the resource must be a Custom UI.
45
+ *
46
+ * @param modules Modules declared in the manifest
47
+ * @param resources Resources declared in the manifest
48
+ */
49
+ function getResourceTypeIndex(modules, resources) {
50
+ const modulesEntries = Object.entries(modules);
51
+ const resourceKeys = resources.map((r) => r.key);
52
+ const indexModuleDefinition = (acc, moduleType, moduleDefinition) => {
53
+ var _a;
54
+ const moduleResourceKey = moduleDefinition['resource'];
55
+ if (resourceKeys.includes(moduleResourceKey)) {
56
+ const type = moduleDefinition['render'] === 'native' ? 'ui-kit-2' : 'custom-ui';
57
+ const existingIndexEntry = acc[moduleResourceKey];
58
+ if (existingIndexEntry && existingIndexEntry.type !== type) {
59
+ devkit_1.logger.warn(`Inconsistent resource mapping in manifest.yml: Module ${moduleType} (${moduleDefinition['key']}) declares its resource to be of type ${type} but other modules with keys [${existingIndexEntry.modules
60
+ .map(([, m]) => m['key'])
61
+ .join(', ')}] pointing to the same resource appear to be of a different type`);
62
+ }
63
+ const existingModules = (_a = existingIndexEntry === null || existingIndexEntry === void 0 ? void 0 : existingIndexEntry.modules) !== null && _a !== void 0 ? _a : [];
64
+ return Object.assign(Object.assign({}, acc), { [moduleResourceKey]: {
65
+ type,
66
+ modules: [...existingModules, [moduleType, moduleDefinition]],
67
+ } });
68
+ }
69
+ else {
70
+ return acc;
71
+ }
72
+ };
73
+ const resourceTypeIndex = modulesEntries.reduce((acc, [moduleType, moduleDefinitions]) => {
74
+ return moduleDefinitions.reduce((innerAcc, moduleDefinition) => indexModuleDefinition(innerAcc, moduleType, moduleDefinition), acc);
75
+ }, {});
76
+ const resourceTypeIndexKeySet = new Set(Object.keys(resourceTypeIndex));
77
+ const resourceKeySet = new Set(resourceKeys);
78
+ if (resourceTypeIndexKeySet.size === resourceKeySet.size &&
79
+ [...resourceTypeIndexKeySet].every((k) => resourceKeySet.has(k))) {
80
+ return resourceTypeIndex;
81
+ }
82
+ else {
83
+ const missingResourceKeys = [...resourceKeySet].filter((k) => !resourceTypeIndexKeySet.has(k));
84
+ devkit_1.logger.warn(`Failed to find module definition for resources with keys ${missingResourceKeys}`);
85
+ return resourceTypeIndex;
86
+ }
87
+ }
88
+ /**
89
+ * Returns the final resource path based on the given resource type.
90
+ *
91
+ * Verifies that the path/file exists in the computed directory. UI Kit 2 builds are expected to produce an accepted
92
+ * bundle filename.
93
+ *
94
+ * @param resourcePath Path where all resource build artifacts are placed, relative to the app root directory
95
+ * @param resourceType Type of the given resource, `ui-kit-2` or `custom-ui`
96
+ * @param resource Resource to process
97
+ * @param absoluteOutputPath Absolute project output path
98
+ */
99
+ function getVerifiedResourcePath(resourcePath, resourceType, resource, absoluteOutputPath) {
100
+ const resourceProjectName = resource.path;
101
+ const relativeResourcePath = (0, path_1.join)(resourcePath, resourceProjectName);
102
+ const absoluteResourcePath = (0, path_1.join)(absoluteOutputPath, relativeResourcePath);
103
+ if (!(0, fs_1.existsSync)(absoluteResourcePath)) {
104
+ throw new Error(`Failed to patch resource with key '${resource.key}': No resource artifacts found in ${absoluteOutputPath}. Did you forget to build the resource?`);
105
+ }
106
+ if (resourceType === 'custom-ui') {
107
+ devkit_1.logger.info(`Detected resource '${resource.key}' as Custom UI dependency`);
108
+ return relativeResourcePath;
109
+ }
110
+ devkit_1.logger.info(`Detected resource '${resource.key}' as UI Kit 2 dependency`);
111
+ const acceptedUiKit2EntryPoints = [
112
+ 'index.js',
113
+ 'index.jsx',
114
+ 'main.js',
115
+ 'main.jsx',
116
+ ];
117
+ const entryPointFile = acceptedUiKit2EntryPoints.find((entryPointFile) => (0, fs_1.existsSync)((0, path_1.join)(absoluteResourcePath, entryPointFile)));
118
+ if (entryPointFile) {
119
+ return `${relativeResourcePath}/${entryPointFile}`;
120
+ }
121
+ else {
122
+ throw new Error(`Failed to patch resource with key '${resource.key}': Could not find entry point file in ${absoluteResourcePath}. Make sure the UI Kit 2 build produces a files with one of these names: [${acceptedUiKit2EntryPoints.join(',')}]`);
123
+ }
124
+ }
125
+ function patchResource(resourcePath, resource, absoluteOutputPath, resourceContext) {
126
+ devkit_1.logger.info(`Patching resource with key '${resource.key}'...`);
127
+ if (!resourceContext) {
128
+ devkit_1.logger.warn(`Resource with key '${resource.key}' appears not to be used by any module. Skip patching.`);
129
+ return resource;
130
+ }
131
+ const verifiedResourcePath = getVerifiedResourcePath(resourcePath, resourceContext.type, resource, absoluteOutputPath);
132
+ return Object.assign(Object.assign({}, resource), { path: verifiedResourcePath });
30
133
  }
31
134
  //# sourceMappingURL=patch-manifest-yml.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"patch-manifest-yml.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/build/lib/patch-manifest-yml.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,uCAAuD;AAIvD,oEAG2C;AAI3C;;;;;;;GAOG;AACH,SAAsB,gBAAgB,CAAC,OAAgB;;QACrD,MAAM,YAAY,GAAG,IAAA,0BAAiB,EACpC,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,EACzC,cAAc,CACf,CAAC;QAEF,eAAM,CAAC,IAAI,CAAC,YAAY,YAAY,KAAK,CAAC,CAAC;QAE3C,MAAM,cAAc,GAAG,MAAM,IAAA,8BAAe,EAAC,YAAY,CAAC,CAAC;QAE3D,MAAM,SAAS,GAAc,cAAc,CAAC,SAAS,IAAI,EAAE,CAAC;QAC5D,MAAM,eAAe,mCAChB,cAAc,KACjB,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,GACxE,CAAC;QAEF,IAAA,+BAAgB,EAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAEhD,eAAM,CAAC,IAAI,CAAC,iBAAiB,YAAY,GAAG,CAAC,CAAC;IAChD,CAAC;CAAA;AAnBD,4CAmBC;AAED,SAAS,aAAa,CACpB,YAAoB,EACpB,QAA+B;IAE/B,uCACK,QAAQ,KACX,IAAI,EAAE,GAAG,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,IACxC;AACJ,CAAC"}
1
+ {"version":3,"file":"patch-manifest-yml.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/build/lib/patch-manifest-yml.ts"],"names":[],"mappings":";;;;AAAA,+BAAqC;AACrC,uCAAuD;AAIvD,oEAG2C;AAC3C,2BAAgC;AA6BhC;;;;;;;GAOG;AACH,SAAsB,gBAAgB,CAAC,OAAgB;;QACrD,MAAM,kBAAkB,GAAG,IAAA,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E,CAAC;QACrB,eAAM,CAAC,IAAI,CACT,sBAAsB,QAAQ,CAAC,GAAG,wDAAwD,CAC3F,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,oBAAoB,GAAG,uBAAuB,CAClD,YAAY,EACZ,eAAe,CAAC,IAAI,EACpB,QAAQ,EACR,kBAAkB,CACnB,CAAC;IAEF,uCACK,QAAQ,KACX,IAAI,EAAE,oBAAoB,IAC1B;AACJ,CAAC"}
@@ -1,14 +1,16 @@
1
- import type { ExecutorContext } from '@nx/devkit';
1
+ import { ExecutorContext } from '@nx/devkit';
2
2
  import { Resources } from '@forge/manifest';
3
3
  import { NormalizedOptions } from '../schema';
4
- type Options = Pick<NormalizedOptions, 'root' | 'outputPath' | 'customUIPath'>;
4
+ type Options = Pick<NormalizedOptions, 'root' | 'outputPath' | 'resourceOutputPathMap'> & {
5
+ resourcePath: string;
6
+ };
5
7
  /**
6
- * Verifies that Custom UI projects are correctly linked to the Nx Forge app and copies build artifacts into the app's
8
+ * Verifies that resource projects are correctly linked to the Nx Forge app and copies build artifacts into the app's
7
9
  * output directory. In particular, this will make sure that each resource listed in the manifest.yml has its path
8
10
  * configured to point to a Nx project in this workspace.
9
11
  *
10
12
  * @param options Executor options
11
13
  * @param context Executor context
12
14
  */
13
- export declare function processCustomUIDependencies(options: Options, context: ExecutorContext): Promise<Resources>;
15
+ export declare function processResourceDependencies(options: Options, context: ExecutorContext): Promise<Resources>;
14
16
  export {};
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processResourceDependencies = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_extra_1 = require("fs-extra");
6
+ const fs_1 = require("fs");
7
+ const devkit_1 = require("@nx/devkit");
8
+ const manifest_yml_1 = require("../../../utils/forge/manifest-yml");
9
+ /**
10
+ * Verifies that resource projects are correctly linked to the Nx Forge app and copies build artifacts into the app's
11
+ * output directory. In particular, this will make sure that each resource listed in the manifest.yml has its path
12
+ * configured to point to a Nx project in this workspace.
13
+ *
14
+ * @param options Executor options
15
+ * @param context Executor context
16
+ */
17
+ function processResourceDependencies(options, context) {
18
+ var _a;
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ const manifestPath = (0, devkit_1.joinPathFragments)(context.root, context.projectsConfigurations.projects[context.projectName].root, 'manifest.yml');
21
+ const manifestSchema = yield (0, manifest_yml_1.readManifestYml)(manifestPath);
22
+ const resources = (_a = manifestSchema.resources) !== null && _a !== void 0 ? _a : [];
23
+ resources.forEach((r) => verifyAndCopyResourceDependency(r, context, options));
24
+ return resources;
25
+ });
26
+ }
27
+ exports.processResourceDependencies = processResourceDependencies;
28
+ const getResourceOutputPath = (options, resourceProjectGraphNode, configurationName) => {
29
+ var _a, _b;
30
+ const resourceProjectName = resourceProjectGraphNode.data.name;
31
+ const maybeResourceOutputPath = options.resourceOutputPathMap[resourceProjectName];
32
+ if (maybeResourceOutputPath &&
33
+ typeof maybeResourceOutputPath === 'string' &&
34
+ maybeResourceOutputPath !== '') {
35
+ return maybeResourceOutputPath;
36
+ }
37
+ const maybeBuildTargetOutputPathOption = (_b = (_a = resourceProjectGraphNode.data.targets['build']) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.outputPath;
38
+ if (maybeBuildTargetOutputPathOption) {
39
+ return maybeBuildTargetOutputPathOption;
40
+ }
41
+ const [firstOutputDefinition, ...otherOutputDefinitions] = (0, devkit_1.getOutputsForTargetAndConfiguration)({
42
+ project: resourceProjectName,
43
+ target: 'build',
44
+ configuration: configurationName,
45
+ }, {}, resourceProjectGraphNode);
46
+ if (firstOutputDefinition && otherOutputDefinitions.length === 0) {
47
+ return firstOutputDefinition;
48
+ }
49
+ throw new Error(`Failed to infer output path for resource project '${resourceProjectName}': Try to define an explicit output path mapping using the 'resourceOutputPathMap' option of this executor. Add an entry to the mapping object as follows: {'${resourceProjectName}': '<replace-with-project-output-path>'}.`);
50
+ };
51
+ const verifyAndCopyResourceDependency = (resource, context, options) => {
52
+ const resourceProjectName = resource.path;
53
+ const resourceProjectGraphNode = context.projectGraph.nodes[resourceProjectName];
54
+ const resourceProjectConfiguration = resourceProjectGraphNode === null || resourceProjectGraphNode === void 0 ? void 0 : resourceProjectGraphNode.data;
55
+ if (!resourceProjectGraphNode || !resourceProjectConfiguration) {
56
+ throw new Error(`Nx workspace is missing project for resource path ${resourceProjectName}. Make sure the resource path references a project in your Nx workspace.`);
57
+ }
58
+ const resourceBuildTargetOutputPath = getResourceOutputPath(options, resourceProjectGraphNode, context.configurationName);
59
+ const absoluteResourceBuildTargetOutputPath = (0, devkit_1.joinPathFragments)(context.root, resourceBuildTargetOutputPath);
60
+ if (!resourceBuildTargetOutputPath ||
61
+ !(0, fs_1.existsSync)(absoluteResourceBuildTargetOutputPath) ||
62
+ (0, fs_1.readdirSync)(absoluteResourceBuildTargetOutputPath).length === 0) {
63
+ throw new Error(`Project ${resourceProjectName} has no build artifacts in output directory '${resourceBuildTargetOutputPath}'. Make sure the project produces compatible build artifacts.`);
64
+ }
65
+ devkit_1.logger.info(`Copying ${resourceProjectName} resource build artifacts...`);
66
+ (0, fs_extra_1.copySync)(absoluteResourceBuildTargetOutputPath, (0, devkit_1.joinPathFragments)(options.root, options.outputPath, options.resourcePath, resourceProjectName), { recursive: true });
67
+ devkit_1.logger.info(`Done copying ${resourceProjectName} resource build artifacts.`);
68
+ };
69
+ //# sourceMappingURL=process-resource-dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-resource-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/nx-forge/src/executors/build/lib/process-resource-dependencies.ts"],"names":[],"mappings":";;;;AAAA,uCAAoC;AACpC,2BAA6C;AAC7C,uCAMoB;AAIpB,oEAAoE;AASpE;;;;;;;GAOG;AACH,SAAsB,2BAA2B,CAC/C,OAAgB,EAChB,OAAwB;;;QAExB,MAAM,YAAY,GAAG,IAAA,0BAAiB,EACpC,OAAO,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EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;IACF,eAAM,CAAC,IAAI,CAAC,gBAAgB,mBAAmB,4BAA4B,CAAC,CAAC;AAC/E,CAAC,CAAC"}
@@ -4,6 +4,8 @@ export interface BuildExecutorOptions {
4
4
  watch: boolean;
5
5
  sourceMap?: boolean | 'hidden';
6
6
  webpackConfig?: string;
7
+ resourceOutputPathMap?: Record<string, string>;
8
+ uiKit2Packaging: boolean;
7
9
  }
8
10
 
9
11
  export interface NormalizedOptions extends BuildExecutorOptions {
@@ -13,4 +15,5 @@ export interface NormalizedOptions extends BuildExecutorOptions {
13
15
  customUIPath: string;
14
16
  outputPath: string;
15
17
  outputFileName: string;
18
+ resourceOutputPathMap: Record<string, string>;
16
19
  }
@@ -14,6 +14,11 @@
14
14
  "type": "string",
15
15
  "description": "Custom UI output path relative to the outputPath."
16
16
  },
17
+ "resourceOutputPathMap": {
18
+ "type": "object",
19
+ "description": "Map of resource project names to their respective output path.",
20
+ "default": {}
21
+ },
17
22
  "watch": {
18
23
  "type": "boolean",
19
24
  "description": "Enable re-building when files change.",
@@ -36,6 +41,11 @@
36
41
  "x-completion-type": "file",
37
42
  "x-completion-glob": "webpack?(*)@(.js|.ts)",
38
43
  "x-priority": "important"
44
+ },
45
+ "uiKit2Packaging": {
46
+ "type": "boolean",
47
+ "description": "Enables UI Kit 2 compatible packaging.",
48
+ "default": false
39
49
  }
40
50
  },
41
51
  "required": ["outputPath"]
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
- const process_custom_ui_dependencies_1 = require("../build/lib/process-custom-ui-dependencies");
6
+ const process_resource_dependencies_1 = require("../build/lib/process-resource-dependencies");
7
7
  const patch_manifest_yml_1 = require("../build/lib/patch-manifest-yml");
8
8
  const generate_package_json_1 = require("../build/lib/generate-package-json");
9
9
  const copy_forge_app_assets_1 = require("../build/lib/copy-forge-app-assets");
10
10
  function normalizeOptions(options, root, sourceRoot, projectRoot) {
11
- var _a;
11
+ var _a, _b;
12
12
  return Object.assign(Object.assign({}, options), { root,
13
13
  sourceRoot,
14
- projectRoot, resourcePath: (_a = options.resourcePath) !== null && _a !== void 0 ? _a : 'resources' });
14
+ projectRoot, resourcePath: (_a = options.resourcePath) !== null && _a !== void 0 ? _a : 'resources', resourceOutputPathMap: (_b = options.resourceOutputPathMap) !== null && _b !== void 0 ? _b : {} });
15
15
  }
16
16
  exports.normalizeOptions = normalizeOptions;
17
17
  function runExecutor(rawOptions, context) {
@@ -25,9 +25,9 @@ function runExecutor(rawOptions, context) {
25
25
  }
26
26
  const options = normalizeOptions(rawOptions, context.root, sourceRoot, root);
27
27
  (0, copy_forge_app_assets_1.copyForgeAppAssets)(options);
28
- const customUIResources = yield (0, process_custom_ui_dependencies_1.processCustomUIDependencies)(Object.assign(Object.assign({}, options), { customUIPath: options.resourcePath }), context);
29
- yield (0, patch_manifest_yml_1.patchManifestYml)(Object.assign(Object.assign({}, options), { customUIPath: options.resourcePath }));
30
- (0, generate_package_json_1.generatePackageJson)(context.projectName, context.projectGraph, customUIResources, options);
28
+ const resources = yield (0, process_resource_dependencies_1.processResourceDependencies)(Object.assign(Object.assign({}, options), { resourcePath: options.resourcePath }), context);
29
+ yield (0, patch_manifest_yml_1.patchManifestYml)(Object.assign(Object.assign({}, options), { resourcePath: options.resourcePath }));
30
+ (0, generate_package_json_1.generatePackageJson)(context.projectName, context.projectGraph, resources, options);
31
31
  devkit_1.logger.info('Executor ran for package');
32
32
  return {
33
33
  success: true,
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/executors/package/executor.ts"],"names":[],"mappings":";;;;AAAA,uCAAqD;AAErD,gGAA0F;AAC1F,wEAAmE;AACnE,8EAAyE;AACzE,8EAAwE;AAExE,SAAgB,gBAAgB,CAC9B,OAA8B,EAC9B,IAAY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O,CACR,CAAC;QAEF,eAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACxC,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;CAAA;AArCD,8BAqCC"}
@@ -1,6 +1,8 @@
1
1
  export interface PackageExecutorSchema {
2
2
  outputPath: string;
3
3
  resourcePath?: string;
4
+ resourceOutputPathMap?: Record<string, string>;
5
+ uiKit2Packaging: boolean;
4
6
  }
5
7
 
6
8
  export interface NormalizedOptions extends PackageExecutorSchema {
@@ -9,4 +11,5 @@ export interface NormalizedOptions extends PackageExecutorSchema {
9
11
  projectRoot: string;
10
12
  resourcePath: string;
11
13
  outputPath: string;
14
+ resourceOutputPathMap: Record<string, string>;
12
15
  }
@@ -12,6 +12,16 @@
12
12
  "resourcePath": {
13
13
  "type": "string",
14
14
  "description": "Path where resource files such as Custom UI output is placed relative to the outputPath."
15
+ },
16
+ "resourceOutputPathMap": {
17
+ "type": "object",
18
+ "description": "Map of resource project names to their respective output path.",
19
+ "default": {}
20
+ },
21
+ "uiKit2Packaging": {
22
+ "type": "boolean",
23
+ "description": "Enables UI Kit 2 compatible packaging.",
24
+ "default": false
15
25
  }
16
26
  },
17
27
  "required": ["outputPath"]
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processCustomUIDependencies = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs_extra_1 = require("fs-extra");
6
- const fs_1 = require("fs");
7
- const devkit_1 = require("@nx/devkit");
8
- const manifest_yml_1 = require("../../../utils/forge/manifest-yml");
9
- /**
10
- * Verifies that Custom UI projects are correctly linked to the Nx Forge app and copies build artifacts into the app's
11
- * output directory. In particular, this will make sure that each resource listed in the manifest.yml has its path
12
- * configured to point to a Nx project in this workspace.
13
- *
14
- * @param options Executor options
15
- * @param context Executor context
16
- */
17
- function processCustomUIDependencies(options, context) {
18
- var _a;
19
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
- const manifestPath = (0, devkit_1.joinPathFragments)(context.root, context.projectsConfigurations.projects[context.projectName].root, 'manifest.yml');
21
- const manifestSchema = yield (0, manifest_yml_1.readManifestYml)(manifestPath);
22
- const resources = (_a = manifestSchema.resources) !== null && _a !== void 0 ? _a : [];
23
- resources.forEach((r) => verifyAndCopyCustomUIDependency(r, context, options));
24
- return resources;
25
- });
26
- }
27
- exports.processCustomUIDependencies = processCustomUIDependencies;
28
- const verifyAndCopyCustomUIDependency = (resource, context, options) => {
29
- var _a, _b;
30
- const customUIProjectName = resource.path;
31
- const customUIProjectConfiguration = context.projectsConfigurations.projects[customUIProjectName];
32
- if (!customUIProjectConfiguration) {
33
- throw new Error(`Nx workspace is missing project for Custom UI path ${customUIProjectName}. Make sure the Custom UI resource path references a project in your Nx workspace.`);
34
- }
35
- const customUIBuildTargetOutputPath = (_b = (_a = customUIProjectConfiguration.targets['build']) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.outputPath;
36
- const absoluteCustomUIBuildTargetOutputPath = (0, devkit_1.joinPathFragments)(context.root, customUIBuildTargetOutputPath);
37
- if (!customUIBuildTargetOutputPath ||
38
- !(0, fs_1.existsSync)(absoluteCustomUIBuildTargetOutputPath) ||
39
- (0, fs_1.readdirSync)(absoluteCustomUIBuildTargetOutputPath).length === 0) {
40
- throw new Error(`Project ${customUIProjectName} is missing build artifacts. Make sure the project produces Custom UI compatible build artifacts.`);
41
- }
42
- devkit_1.logger.info(`Copying ${customUIProjectName} Custom UI build artifacts...`);
43
- (0, fs_extra_1.copySync)(absoluteCustomUIBuildTargetOutputPath, (0, devkit_1.joinPathFragments)(options.root, options.outputPath, options.customUIPath, customUIProjectName), { recursive: true });
44
- devkit_1.logger.info(`Done copying ${customUIProjectName} Custom UI build artifacts.`);
45
- };
46
- //# sourceMappingURL=process-custom-ui-dependencies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-custom-ui-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/n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