@toolsplus/nx-forge 6.0.1 → 6.0.2
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 +3 -2
- package/src/executors/build/executor.js +24 -40
- package/src/executors/build/executor.js.map +1 -1
- package/src/executors/build/lib/normalize-options.js +9 -2
- package/src/executors/build/lib/normalize-options.js.map +1 -1
- package/src/executors/build/lib/patch-manifest-yml.js +33 -22
- package/src/executors/build/lib/patch-manifest-yml.js.map +1 -1
- package/src/executors/build/lib/process-resource-dependencies.js +14 -12
- package/src/executors/build/lib/process-resource-dependencies.js.map +1 -1
- package/src/executors/deploy/executor.js +24 -24
- package/src/executors/deploy/executor.js.map +1 -1
- package/src/executors/deploy/lib/transform-manifest-yml.js +5 -5
- package/src/executors/deploy/lib/transform-manifest-yml.js.map +1 -1
- package/src/executors/install/executor.js +19 -22
- package/src/executors/install/executor.js.map +1 -1
- package/src/executors/package/executor.js +31 -29
- package/src/executors/package/executor.js.map +1 -1
- package/src/executors/register/executor.js +23 -26
- package/src/executors/register/executor.js.map +1 -1
- package/src/executors/register/lib/normalize-options.js +6 -2
- package/src/executors/register/lib/normalize-options.js.map +1 -1
- package/src/executors/register/lib/patch-manifest-yml.js +16 -13
- package/src/executors/register/lib/patch-manifest-yml.js.map +1 -1
- package/src/executors/tunnel/executor.js +32 -49
- package/src/executors/tunnel/executor.js.map +1 -1
- package/src/executors/tunnel/lib/extract-custom-ui-projects.js +14 -19
- package/src/executors/tunnel/lib/extract-custom-ui-projects.js.map +1 -1
- package/src/executors/tunnel/lib/run-tunnel.js +72 -76
- package/src/executors/tunnel/lib/run-tunnel.js.map +1 -1
- package/src/executors/tunnel/lib/start-custom-uis.js +6 -9
- package/src/executors/tunnel/lib/start-custom-uis.js.map +1 -1
- package/src/generators/application/generator.js +84 -57
- package/src/generators/application/generator.js.map +1 -1
- package/src/generators/application/lib/add-project-dependencies.js +33 -32
- package/src/generators/application/lib/add-project-dependencies.js.map +1 -1
- package/src/generators/application/lib/normalize-options.js +26 -21
- package/src/generators/application/lib/normalize-options.js.map +1 -1
- package/src/generators/init/generator.js +16 -20
- package/src/generators/init/generator.js.map +1 -1
- package/src/graph/create-dependencies.js +11 -23
- package/src/graph/create-dependencies.js.map +1 -1
- package/src/migrations/update-2-3-0/remove-implicit-custom-ui-dependencies.js +15 -18
- package/src/migrations/update-2-3-0/remove-implicit-custom-ui-dependencies.js.map +1 -1
- package/src/migrations/update-2-3-0/utils/manifest.js +3 -3
- package/src/migrations/update-2-3-0/utils/manifest.js.map +1 -1
- package/src/migrations/update-3-0-0-webpack-config-setup/update-3-0-0-webpack-config-setup.js +15 -18
- package/src/migrations/update-3-0-0-webpack-config-setup/update-3-0-0-webpack-config-setup.js.map +1 -1
- package/src/shared/manifest/util-manifest.d.ts +18 -9
- package/src/shared/manifest/util-manifest.js +53 -37
- package/src/shared/manifest/util-manifest.js.map +1 -1
- package/src/utils/forge/async-commands.js +1 -1
- package/src/utils/forge/async-commands.js.map +1 -1
- package/src/utils/forge/manifest-yml.d.ts +3 -1
- package/src/utils/forge/manifest-yml.js +8 -7
- package/src/utils/forge/manifest-yml.js.map +1 -1
- package/src/utils/forge/yaml-validator.d.ts +19 -0
- package/src/utils/forge/yaml-validator.js +73 -0
- package/src/utils/forge/yaml-validator.js.map +1 -0
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { ManifestSchema } from '@forge/manifest';
|
|
2
2
|
import { HostedResourcesSchema } from '@forge/manifest/out/schema/manifest';
|
|
3
|
-
export type ResourceType = 'ui-kit' | 'custom-ui' | '
|
|
3
|
+
export type ResourceType = 'ui-kit' | 'custom-ui' | 'static';
|
|
4
4
|
export type ResourceTypeIndex = {
|
|
5
5
|
[resourceKey: string]: ResourceType;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Computes an index from resource key to resource type which is either `ui-kit`,
|
|
9
|
-
* `custom-ui` or `
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* its resource must be a Custom UI. In all other cases, the resource type is
|
|
14
|
-
* Generic.
|
|
9
|
+
* `custom-ui` or `static`.
|
|
10
|
+
*
|
|
11
|
+
* Refer to the docs on {@link resourceTypeByResourceDefinition} for details
|
|
12
|
+
* on how the resource type is inferred.
|
|
15
13
|
*
|
|
16
14
|
* @param manifestSchema Complete manifest definition to analyze
|
|
17
15
|
*/
|
|
18
16
|
export declare const getResourceTypeIndex: (manifestSchema: ManifestSchema) => ResourceTypeIndex;
|
|
19
17
|
/**
|
|
20
|
-
* Determines if type of the given resource.
|
|
21
|
-
*
|
|
18
|
+
* Determines if type of the given resource.
|
|
19
|
+
*
|
|
20
|
+
* The resource type is determined by the following reduction:
|
|
21
|
+
*
|
|
22
|
+
* - If the resource is referenced by a module as a 'resource', infer a Custom
|
|
23
|
+
* UI or UI Kit resource.
|
|
24
|
+
* - If the resource key is referenced via resource string interpolation
|
|
25
|
+
* (resource:<resource-key>;) anywhere in the manifest, infer a static resource.
|
|
26
|
+
* - Else infer Custom UI. These kind of resources are typically used as Modal
|
|
27
|
+
* dialogs in Custom UIs. They are not referenced in the manifest and instead,
|
|
28
|
+
* opened via @forge/bridge in Custom UI code.
|
|
29
|
+
*
|
|
30
|
+
* @see https://developer.atlassian.com/platform/forge/apis-reference/ui-api-bridge/modal/
|
|
22
31
|
*
|
|
23
32
|
* @param manifestSchema Complete manifest definition
|
|
24
33
|
* @param resource Resource to resolve against the manifest definition
|
|
@@ -13,7 +13,7 @@ const isObject = (v) => typeof v === 'object' && v !== null;
|
|
|
13
13
|
* `native`
|
|
14
14
|
* - Custom UI: module has the `resource` property and the `render` property is
|
|
15
15
|
* not `native` or missing
|
|
16
|
-
* -
|
|
16
|
+
* - Static: none of the above, consider it a static resource
|
|
17
17
|
*
|
|
18
18
|
* @param moduleDefinition Module definition to analyze
|
|
19
19
|
*/
|
|
@@ -22,55 +22,71 @@ const resourceTypeByModuleDefinition = (moduleDefinition) => {
|
|
|
22
22
|
return 'ui-kit';
|
|
23
23
|
if (!!moduleDefinition['resource'] && moduleDefinition['render'] !== 'native')
|
|
24
24
|
return 'custom-ui';
|
|
25
|
-
return '
|
|
25
|
+
return 'static';
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* Computes an index from resource key to resource type which is either `ui-kit`,
|
|
29
|
-
* `custom-ui` or `
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* its resource must be a Custom UI. In all other cases, the resource type is
|
|
34
|
-
* Generic.
|
|
29
|
+
* `custom-ui` or `static`.
|
|
30
|
+
*
|
|
31
|
+
* Refer to the docs on {@link resourceTypeByResourceDefinition} for details
|
|
32
|
+
* on how the resource type is inferred.
|
|
35
33
|
*
|
|
36
34
|
* @param manifestSchema Complete manifest definition to analyze
|
|
37
35
|
*/
|
|
38
|
-
const getResourceTypeIndex = (manifestSchema) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return Object.assign(Object.assign({}, acc), { [resourceKey]: resourceType });
|
|
51
|
-
}
|
|
52
|
-
return acc;
|
|
53
|
-
}, {});
|
|
54
|
-
};
|
|
36
|
+
const getResourceTypeIndex = (manifestSchema) => (manifestSchema.resources || []).reduce((acc, resource) => {
|
|
37
|
+
const resourceKey = resource.key;
|
|
38
|
+
const resourceType = (0, exports.resourceTypeByResourceDefinition)(manifestSchema)(resource);
|
|
39
|
+
const existingIndexEntry = acc[resourceKey];
|
|
40
|
+
if (existingIndexEntry && existingIndexEntry !== resourceType) {
|
|
41
|
+
devkit_1.logger.warn(`Inconsistent resource type inference: Resource with key ${resource.key} has been inferred as type '${resourceType}' but has already been inferred as type '${existingIndexEntry}'`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...acc,
|
|
45
|
+
[resourceKey]: resourceType,
|
|
46
|
+
};
|
|
47
|
+
}, {});
|
|
55
48
|
exports.getResourceTypeIndex = getResourceTypeIndex;
|
|
56
49
|
/**
|
|
57
|
-
* Determines if type of the given resource.
|
|
58
|
-
*
|
|
50
|
+
* Determines if type of the given resource.
|
|
51
|
+
*
|
|
52
|
+
* The resource type is determined by the following reduction:
|
|
53
|
+
*
|
|
54
|
+
* - If the resource is referenced by a module as a 'resource', infer a Custom
|
|
55
|
+
* UI or UI Kit resource.
|
|
56
|
+
* - If the resource key is referenced via resource string interpolation
|
|
57
|
+
* (resource:<resource-key>;) anywhere in the manifest, infer a static resource.
|
|
58
|
+
* - Else infer Custom UI. These kind of resources are typically used as Modal
|
|
59
|
+
* dialogs in Custom UIs. They are not referenced in the manifest and instead,
|
|
60
|
+
* opened via @forge/bridge in Custom UI code.
|
|
61
|
+
*
|
|
62
|
+
* @see https://developer.atlassian.com/platform/forge/apis-reference/ui-api-bridge/modal/
|
|
59
63
|
*
|
|
60
64
|
* @param manifestSchema Complete manifest definition
|
|
61
65
|
* @param resource Resource to resolve against the manifest definition
|
|
62
66
|
*/
|
|
63
|
-
const resourceTypeByResourceDefinition = (manifestSchema) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const resourceTypeByResourceDefinition = (manifestSchema) => {
|
|
68
|
+
const manifestSchemaString = JSON.stringify(manifestSchema);
|
|
69
|
+
return (resource) => {
|
|
70
|
+
var _a;
|
|
71
|
+
for (const moduleDefinition of (0, manifest_1.getAllModules)((_a = manifestSchema.modules) !== null && _a !== void 0 ? _a : {})) {
|
|
72
|
+
if (isObject(moduleDefinition) &&
|
|
73
|
+
Object.hasOwn(moduleDefinition, 'resource') &&
|
|
74
|
+
typeof moduleDefinition['resource'] === 'string' &&
|
|
75
|
+
moduleDefinition['resource'] === resource.key) {
|
|
76
|
+
return resourceTypeByModuleDefinition(moduleDefinition);
|
|
77
|
+
}
|
|
71
78
|
}
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
// If the resource key is referenced in the manifest via a resource
|
|
80
|
+
// string interpolation, assume it is a static resource
|
|
81
|
+
if (manifestSchemaString.includes(`resource:${resource.key};`)) {
|
|
82
|
+
return 'static';
|
|
83
|
+
}
|
|
84
|
+
// Assume that the resource is a Custom UI. There may be resources which are
|
|
85
|
+
// not directly referenced in the manifest. For example, UI Kit modal dialogs
|
|
86
|
+
// can be referenced in other Custom UI projects and loaded via @forge/bridge.
|
|
87
|
+
// https://developer.atlassian.com/platform/forge/apis-reference/ui-api-bridge/modal/
|
|
88
|
+
return 'custom-ui';
|
|
89
|
+
};
|
|
74
90
|
};
|
|
75
91
|
exports.resourceTypeByResourceDefinition = resourceTypeByResourceDefinition;
|
|
76
92
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util-manifest.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/shared/manifest/util-manifest.ts"],"names":[],"mappings":";;;AAAA,8CAAgE;AAEhE,uCAAoC;AAEpC,8CAA8C;AAC9C,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAe,EAAE,CAC3C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;AAItC;;;;;;;;;;;GAWG;AACH,MAAM,8BAA8B,GAAG,CACrC,gBAAwB,EACV,EAAE;IAChB,IAAI,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,QAAQ;QAC3E,OAAO,QAAQ,CAAC;IAClB,IAAI,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,QAAQ;QAC3E,OAAO,WAAW,CAAC;IACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"util-manifest.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/shared/manifest/util-manifest.ts"],"names":[],"mappings":";;;AAAA,8CAA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cliProcess = (0, child_process_1.spawn)(pmc.exec, ['forge', ...args], {
|
|
15
15
|
cwd: opts.cwd,
|
|
16
|
-
env:
|
|
16
|
+
env: { ...process.env, ...opts.env },
|
|
17
17
|
stdio: [process.stdin, process.stdout, process.stderr],
|
|
18
18
|
shell: true,
|
|
19
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-commands.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/utils/forge/async-commands.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AACtC,uCAAsD;AAEtD;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAClC,IAAc,EACd,OAAkD,EAAE,EACrC,EAAE;IACjB,MAAM,GAAG,GAAG,IAAA,iCAAwB,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,qBAAK,EAAC,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE;QACrD,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,
|
|
1
|
+
{"version":3,"file":"async-commands.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/utils/forge/async-commands.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AACtC,uCAAsD;AAEtD;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAClC,IAAc,EACd,OAAkD,EAAE,EACrC,EAAE;IACjB,MAAM,GAAG,GAAG,IAAA,iCAAwB,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,IAAA,qBAAK,EAAC,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE;QACrD,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;QACpC,KAAK,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;QACtD,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;YACvC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,SAAS,CAAC,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;QACH,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;YACtC,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAvBW,QAAA,oBAAoB,wBAuB/B"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ManifestSchema } from '@forge/manifest';
|
|
2
2
|
export declare const validateManifestContent: (manifestContent: ManifestSchema) => Promise<ManifestSchema>;
|
|
3
|
-
export declare const readManifestYml: (path: string
|
|
3
|
+
export declare const readManifestYml: (path: string, options?: {
|
|
4
|
+
interpolate: boolean;
|
|
5
|
+
}) => Promise<ManifestSchema>;
|
|
4
6
|
/**
|
|
5
7
|
* Writes the given manifest file to the specified file path.
|
|
6
8
|
* @param path File path where to write the file to (incl. manifest.yml).
|
|
@@ -7,21 +7,22 @@ const FULL_SCHEMA = tslib_1.__importStar(require("@forge/manifest/out/schema/man
|
|
|
7
7
|
const js_yaml_1 = require("js-yaml");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const util_manifest_1 = require("../../shared/manifest/util-manifest");
|
|
10
|
+
const yaml_validator_1 = tslib_1.__importDefault(require("./yaml-validator"));
|
|
10
11
|
class ManifestYmlValidator extends manifest_1.AbstractValidationProcessor {
|
|
11
|
-
constructor() {
|
|
12
|
+
constructor(options) {
|
|
12
13
|
super([
|
|
13
14
|
new manifest_1.FileValidator(),
|
|
14
|
-
new
|
|
15
|
+
new yaml_validator_1.default(options),
|
|
15
16
|
new manifest_1.SchemaValidator(FULL_SCHEMA),
|
|
16
17
|
]);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
const schemaAndFileValidator = (manifestFilePath) => new ManifestYmlValidator().process(manifestFilePath);
|
|
20
|
+
const schemaAndFileValidator = (options) => (manifestFilePath) => new ManifestYmlValidator(options).process(manifestFilePath);
|
|
20
21
|
const schemaContentValidator = (manifestContent) => new manifest_1.SchemaValidator(FULL_SCHEMA).validate({
|
|
21
22
|
yamlContent: manifestContent,
|
|
22
23
|
});
|
|
23
|
-
const validateManifestSchema = (validator) => (input) =>
|
|
24
|
-
const { manifestObject, success: isManifestParseSuccess, errors, } =
|
|
24
|
+
const validateManifestSchema = (validator) => async (input) => {
|
|
25
|
+
const { manifestObject, success: isManifestParseSuccess, errors, } = await validator(input);
|
|
25
26
|
if (!isManifestParseSuccess || !(manifestObject === null || manifestObject === void 0 ? void 0 : manifestObject.typedContent)) {
|
|
26
27
|
throw new Error(`Failed to validate manifest input: ${(errors || [])
|
|
27
28
|
.map((e) => e.message)
|
|
@@ -32,10 +33,10 @@ const validateManifestSchema = (validator) => (input) => tslib_1.__awaiter(void
|
|
|
32
33
|
throw new Error('Manifest parse result did not return any content.');
|
|
33
34
|
}
|
|
34
35
|
return manifestSchema;
|
|
35
|
-
}
|
|
36
|
+
};
|
|
36
37
|
const validateManifestContent = (manifestContent) => validateManifestSchema(schemaContentValidator)(manifestContent);
|
|
37
38
|
exports.validateManifestContent = validateManifestContent;
|
|
38
|
-
const readManifestYml = (path) => validateManifestSchema(schemaAndFileValidator)(path);
|
|
39
|
+
const readManifestYml = (path, options = { interpolate: true }) => validateManifestSchema(schemaAndFileValidator(options))(path);
|
|
39
40
|
exports.readManifestYml = readManifestYml;
|
|
40
41
|
/**
|
|
41
42
|
* Writes the given manifest file to the specified file path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-yml.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/utils/forge/manifest-yml.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"manifest-yml.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/utils/forge/manifest-yml.ts"],"names":[],"mappings":";;;;AAAA,8CAKyB;AACzB,qGAA+E;AAC/E,qCAA+B;AAC/B,2BAAmC;AAEnC,uEAAqE;AACrE,8EAA6C;AAE7C,MAAM,oBAAqB,SAAQ,sCAA2C;IAC5E,YAAY,OAAiC;QAC3C,KAAK,CAAC;YACJ,IAAI,wBAAa,EAAE;YACnB,IAAI,wBAAa,CAAC,OAAO,CAAC;YAC1B,IAAI,0BAAe,CAAC,WAAW,CAAC;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAMD,MAAM,sBAAsB,GAC1B,CAAC,OAAiC,EAAmC,EAAE,CACvE,CAAC,gBAAwB,EAAE,EAAE,CAC3B,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEhE,MAAM,sBAAsB,GAA4C,CACtE,eAA+B,EAC/B,EAAE,CACF,IAAI,0BAAe,CAAiB,WAAW,CAAC,CAAC,QAAQ,CAAC;IACxD,WAAW,EAAE,eAAe;CAC7B,CAAC,CAAC;AAEL,MAAM,sBAAsB,GAC1B,CAAI,SAAqC,EAAE,EAAE,CAC7C,KAAK,EAAE,KAAQ,EAAE,EAAE;IACjB,MAAM,EACJ,cAAc,EACd,OAAO,EAAE,sBAAsB,EAC/B,MAAM,GACP,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IAE3B,IAAI,CAAC,sBAAsB,IAAI,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,YAAY,CAAA,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CACb,sCAAs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C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC;AANW,QAAA,6BAA6B,iCAMxC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ManifestObject } from '@forge/manifest';
|
|
2
|
+
import { ValidatorInterface } from '@forge/manifest/out/validators/validator-interface';
|
|
3
|
+
import { ManifestValidationResult } from '@forge/manifest/out/types';
|
|
4
|
+
/**
|
|
5
|
+
* Copy of @forge/manifest YamlValidator with the only difference that the
|
|
6
|
+
* validator can be constructed with or without manifest interpolation. The
|
|
7
|
+
* validator provided by @forge/manifest does not provide an option to skip
|
|
8
|
+
* interpolation.
|
|
9
|
+
*/
|
|
10
|
+
declare class YamlValidator<T> implements ValidatorInterface<ManifestObject<T> | undefined, T> {
|
|
11
|
+
protected options: {
|
|
12
|
+
interpolate: boolean;
|
|
13
|
+
};
|
|
14
|
+
constructor(options: {
|
|
15
|
+
interpolate: boolean;
|
|
16
|
+
});
|
|
17
|
+
validate(manifest: ManifestObject<T> | undefined): Promise<ManifestValidationResult<T>>;
|
|
18
|
+
}
|
|
19
|
+
export default YamlValidator;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const manifest_1 = require("@forge/manifest");
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const yaml_1 = require("yaml");
|
|
6
|
+
/**
|
|
7
|
+
* Copy of @forge/manifest YamlValidator with the only difference that the
|
|
8
|
+
* validator can be constructed with or without manifest interpolation. The
|
|
9
|
+
* validator provided by @forge/manifest does not provide an option to skip
|
|
10
|
+
* interpolation.
|
|
11
|
+
*/
|
|
12
|
+
class YamlValidator {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
async validate(manifest) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
if (!(manifest === null || manifest === void 0 ? void 0 : manifest.filePath)) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
manifestObject: manifest,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const content = (0, node_fs_1.readFileSync)(manifest.filePath, 'utf8');
|
|
26
|
+
const parserBuilder = this.options.interpolate
|
|
27
|
+
? new manifest_1.ManifestParserBuilder().withInterpolators()
|
|
28
|
+
: new manifest_1.ManifestParserBuilder();
|
|
29
|
+
const manifestContent = parserBuilder
|
|
30
|
+
.build()
|
|
31
|
+
.parseManifest({ content, filePath: manifest.filePath });
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
manifestObject: {
|
|
35
|
+
filePath: manifest.filePath,
|
|
36
|
+
yamlContent: manifestContent,
|
|
37
|
+
yamlContentByLine: content.split('\n'),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
if (e instanceof yaml_1.YAMLError) {
|
|
43
|
+
const pos = (_a = e.linePos) === null || _a === void 0 ? void 0 : _a[0];
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
errors: [
|
|
47
|
+
{
|
|
48
|
+
message: manifest_1.errors.invalidManifest(e.message.replace(/(at line).+/gms, '').trim()),
|
|
49
|
+
reference: manifest_1.References.InvalidManifest,
|
|
50
|
+
level: 'error',
|
|
51
|
+
line: (_b = pos === null || pos === void 0 ? void 0 : pos.line) !== null && _b !== void 0 ? _b : 0,
|
|
52
|
+
column: (_c = pos === null || pos === void 0 ? void 0 : pos.col) !== null && _c !== void 0 ? _c : 0,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
errors: [
|
|
60
|
+
{
|
|
61
|
+
message: manifest_1.errors.invalidManifest(e.message),
|
|
62
|
+
reference: manifest_1.References.InvalidManifest,
|
|
63
|
+
level: 'error',
|
|
64
|
+
line: 0,
|
|
65
|
+
column: 0,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = YamlValidator;
|
|
73
|
+
//# sourceMappingURL=yaml-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-validator.js","sourceRoot":"","sources":["../../../../../../packages/nx-forge/src/utils/forge/yaml-validator.ts"],"names":[],"mappings":";;AAAA,8CAKyB;AACzB,qCAAuC;AACvC,+BAAiC;AAIjC;;;;;GAKG;AACH,MAAM,aAAa;IAGjB,YAAsB,OAAiC;QAAjC,YAAO,GAAP,OAAO,CAA0B;IAAG,CAAC;IAC3D,KAAK,CAAC,QAAQ,CACZ,QAAuC;;QAEvC,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAA,EAAE,CAAC;YACxB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,cAAc,EAAE,QAAQ;aACzB,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACxD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;gBAC5C,CAAC,CAAC,IAAI,gCAAqB,EAAE,CAAC,iBAAiB,EAAE;gBACjD,CAAC,CAAC,IAAI,gCAAqB,EAAE,CAAC;YAChC,MAAM,eAAe,GAAG,aAAa;iBAClC,KAAK,EAAE;iBACP,aAAa,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3D,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,cAAc,EAAE;oBACd,QAAQ,EAAE,QAAQ,CAAC,QAAQ;oBAC3B,WAAW,EAAE,eAAe;oBAC5B,iBAAiB,EAAE,OAAO,CA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