@nizza/devkit 0.1.0-alpha.1 → 0.1.0-alpha.11
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/cjs/executors/deploy/helpers.cjs +26 -0
- package/dist/cjs/executors/deploy/index.cjs +22 -0
- package/dist/cjs/executors/environments/helpers.cjs +62 -0
- package/dist/cjs/executors/environments/index.cjs +60 -0
- package/dist/cjs/executors/publish/helpers.cjs +51 -0
- package/dist/cjs/executors/publish/index.cjs +53 -0
- package/dist/cjs/executors/shared/utils.cjs +67 -0
- package/dist/cjs/executors/update-executors-file/helpers.cjs +64 -0
- package/dist/cjs/executors/update-executors-file/index.cjs +38 -0
- package/dist/cjs/executors/vtex-link/constants.cjs +9 -0
- package/dist/cjs/executors/vtex-link/helpers.cjs +206 -0
- package/dist/cjs/executors/vtex-link/index.cjs +30 -0
- package/dist/cjs/index.cjs +56 -0
- package/dist/cjs/scripts/changeset-pre-mode.cjs +41 -0
- package/dist/cjs/scripts/index.cjs +7 -0
- package/dist/cjs/shared/logger.cjs +98 -0
- package/dist/cjs/shared/utils.cjs +36 -0
- package/dist/cjs/vite-utils/config-builder/configs/app.cjs +13 -0
- package/dist/cjs/vite-utils/config-builder/configs/base.cjs +58 -0
- package/dist/cjs/vite-utils/config-builder/configs/index.cjs +36 -0
- package/dist/cjs/vite-utils/config-builder/configs/lib.cjs +57 -0
- package/dist/cjs/vite-utils/config-builder/configs/script.cjs +46 -0
- package/dist/cjs/vite-utils/config-builder/main.cjs +42 -0
- package/dist/cjs/vite-utils/config-builder/plugins.cjs +93 -0
- package/dist/cjs/vite-utils/config-builder/shared/types.cjs +33 -0
- package/dist/cjs/vite-utils/config-builder/shared/utils/helpers.cjs +115 -0
- package/dist/cjs/vite-utils/config-builder/shared/utils/projectConfig.cjs +114 -0
- package/dist/cjs/vite-utils/config-builder/shared/utils/viteCommand.cjs +59 -0
- package/dist/{src/vite/plugins/shadow-dom-inject-css/index.js → cjs/vite-utils/plugins/shadow-dom-inject-css/index.cjs} +4 -19
- package/dist/{src/vite/plugins/third-party-css-inject/main.js → cjs/vite-utils/plugins/third-party-css-inject/main.cjs} +13 -14
- package/dist/{src/vite/plugins/third-party-css-inject/utils.js → cjs/vite-utils/plugins/third-party-css-inject/utils.cjs} +9 -21
- package/dist/esm/executors/deploy/helpers.mjs +22 -0
- package/dist/esm/executors/deploy/index.mjs +20 -0
- package/dist/esm/executors/deploy/schema.json +41 -0
- package/dist/esm/executors/environments/helpers.mjs +58 -0
- package/dist/esm/executors/environments/index.mjs +58 -0
- package/dist/esm/executors/environments/schema.json +9 -0
- package/dist/esm/executors/publish/helpers.mjs +48 -0
- package/dist/esm/executors/publish/index.mjs +51 -0
- package/dist/esm/executors/publish/schema.json +19 -0
- package/dist/esm/executors/shared/utils.mjs +62 -0
- package/dist/esm/executors/update-executors-file/helpers.mjs +59 -0
- package/dist/esm/executors/update-executors-file/index.mjs +36 -0
- package/dist/esm/executors/update-executors-file/schema.json +9 -0
- package/dist/esm/executors/vtex-link/constants.mjs +5 -0
- package/dist/esm/executors/vtex-link/helpers.mjs +192 -0
- package/dist/esm/executors/vtex-link/index.mjs +28 -0
- package/dist/esm/executors/vtex-link/schema.json +25 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/scripts/changeset-pre-mode.mjs +39 -0
- package/dist/esm/scripts/index.mjs +1 -0
- package/dist/{src/logger.js → esm/shared/logger.mjs} +28 -39
- package/dist/esm/shared/utils.mjs +33 -0
- package/dist/esm/vite-utils/config-builder/configs/app.mjs +11 -0
- package/dist/{src/vite/config-builder/configs/base.js → esm/vite-utils/config-builder/configs/base.mjs} +23 -22
- package/dist/esm/vite-utils/config-builder/configs/index.mjs +30 -0
- package/dist/{src/vite/config-builder/configs/lib.js → esm/vite-utils/config-builder/configs/lib.mjs} +16 -18
- package/dist/esm/vite-utils/config-builder/configs/script.mjs +44 -0
- package/dist/esm/vite-utils/config-builder/main.mjs +40 -0
- package/dist/esm/vite-utils/config-builder/plugins.mjs +87 -0
- package/dist/{src/vite/config-builder/shared/types.js → esm/vite-utils/config-builder/shared/types.mjs} +2 -27
- package/dist/{src/vite/config-builder/shared/utils/helpers.d.ts → esm/vite-utils/config-builder/shared/utils/helpers.mjs} +33 -24
- package/dist/esm/vite-utils/config-builder/shared/utils/projectConfig.mjs +109 -0
- package/dist/esm/vite-utils/config-builder/shared/utils/viteCommand.mjs +56 -0
- package/dist/esm/vite-utils/plugins/shadow-dom-inject-css/index.mjs +27 -0
- package/dist/esm/vite-utils/plugins/third-party-css-inject/main.mjs +45 -0
- package/dist/esm/vite-utils/plugins/third-party-css-inject/utils.mjs +97 -0
- package/dist/index.d.ts +367 -0
- package/executors.json +29 -0
- package/package.json +52 -6
- package/dist/package.json +0 -13
- package/dist/src/executors/deploy/executor.d.ts +0 -11
- package/dist/src/executors/deploy/executor.d.ts.map +0 -1
- package/dist/src/executors/deploy/executor.js +0 -27
- package/dist/src/executors/deploy/helpers.d.ts +0 -4
- package/dist/src/executors/deploy/helpers.d.ts.map +0 -1
- package/dist/src/executors/deploy/helpers.js +0 -40
- package/dist/src/executors/environments/executor.d.ts +0 -16
- package/dist/src/executors/environments/executor.d.ts.map +0 -1
- package/dist/src/executors/environments/executor.js +0 -59
- package/dist/src/executors/environments/helpers.d.ts +0 -21
- package/dist/src/executors/environments/helpers.d.ts.map +0 -1
- package/dist/src/executors/environments/helpers.js +0 -63
- package/dist/src/executors/publish/executor.d.ts +0 -12
- package/dist/src/executors/publish/executor.d.ts.map +0 -1
- package/dist/src/executors/publish/executor.js +0 -58
- package/dist/src/executors/publish/helpers.d.ts +0 -19
- package/dist/src/executors/publish/helpers.d.ts.map +0 -1
- package/dist/src/executors/publish/helpers.js +0 -52
- package/dist/src/executors/shared/index.d.ts +0 -3
- package/dist/src/executors/shared/index.d.ts.map +0 -1
- package/dist/src/executors/shared/index.js +0 -7
- package/dist/src/executors/shared/types.d.ts +0 -4
- package/dist/src/executors/shared/types.d.ts.map +0 -1
- package/dist/src/executors/shared/types.js +0 -4
- package/dist/src/executors/shared/utils.d.ts +0 -34
- package/dist/src/executors/shared/utils.d.ts.map +0 -1
- package/dist/src/executors/shared/utils.js +0 -74
- package/dist/src/executors/update-executors-file/executor.d.ts +0 -12
- package/dist/src/executors/update-executors-file/executor.d.ts.map +0 -1
- package/dist/src/executors/update-executors-file/executor.js +0 -46
- package/dist/src/executors/update-executors-file/helpers.d.ts +0 -24
- package/dist/src/executors/update-executors-file/helpers.d.ts.map +0 -1
- package/dist/src/executors/update-executors-file/helpers.js +0 -70
- package/dist/src/executors/update-executors-file/types.d.ts +0 -14
- package/dist/src/executors/update-executors-file/types.d.ts.map +0 -1
- package/dist/src/executors/update-executors-file/types.js +0 -4
- package/dist/src/executors/vtex-link/constants.d.ts +0 -4
- package/dist/src/executors/vtex-link/constants.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/constants.js +0 -24
- package/dist/src/executors/vtex-link/executor.d.ts +0 -5
- package/dist/src/executors/vtex-link/executor.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/executor.js +0 -35
- package/dist/src/executors/vtex-link/helpers.d.ts +0 -77
- package/dist/src/executors/vtex-link/helpers.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/helpers.js +0 -187
- package/dist/src/executors/vtex-link/types.d.ts +0 -12
- package/dist/src/executors/vtex-link/types.d.ts.map +0 -1
- package/dist/src/executors/vtex-link/types.js +0 -4
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -6
- package/dist/src/logger.d.ts +0 -34
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/scripts/changeset-pre-mode.d.ts +0 -2
- package/dist/src/scripts/changeset-pre-mode.d.ts.map +0 -1
- package/dist/src/scripts/changeset-pre-mode.js +0 -41
- package/dist/src/shared/index.d.ts +0 -2
- package/dist/src/shared/index.d.ts.map +0 -1
- package/dist/src/shared/index.js +0 -6
- package/dist/src/shared/utils.d.ts +0 -11
- package/dist/src/shared/utils.d.ts.map +0 -1
- package/dist/src/shared/utils.js +0 -22
- package/dist/src/vite/config-builder/configs/app.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/app.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/app.js +0 -19
- package/dist/src/vite/config-builder/configs/base.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/base.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/index.d.ts +0 -7
- package/dist/src/vite/config-builder/configs/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/index.js +0 -28
- package/dist/src/vite/config-builder/configs/lib.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/lib.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/script.d.ts +0 -4
- package/dist/src/vite/config-builder/configs/script.d.ts.map +0 -1
- package/dist/src/vite/config-builder/configs/script.js +0 -42
- package/dist/src/vite/config-builder/index.d.ts +0 -3
- package/dist/src/vite/config-builder/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/index.js +0 -7
- package/dist/src/vite/config-builder/main.d.ts +0 -10
- package/dist/src/vite/config-builder/main.d.ts.map +0 -1
- package/dist/src/vite/config-builder/main.js +0 -37
- package/dist/src/vite/config-builder/plugins.d.ts +0 -30
- package/dist/src/vite/config-builder/plugins.d.ts.map +0 -1
- package/dist/src/vite/config-builder/plugins.js +0 -88
- package/dist/src/vite/config-builder/shared/index.d.ts +0 -3
- package/dist/src/vite/config-builder/shared/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/index.js +0 -7
- package/dist/src/vite/config-builder/shared/types.d.ts +0 -155
- package/dist/src/vite/config-builder/shared/types.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/helpers.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/helpers.js +0 -61
- package/dist/src/vite/config-builder/shared/utils/index.d.ts +0 -4
- package/dist/src/vite/config-builder/shared/utils/index.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/index.js +0 -8
- package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts +0 -60
- package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/projectConfig.js +0 -85
- package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts +0 -24
- package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts.map +0 -1
- package/dist/src/vite/config-builder/shared/utils/viteCommand.js +0 -54
- package/dist/src/vite/index.d.ts +0 -3
- package/dist/src/vite/index.d.ts.map +0 -1
- package/dist/src/vite/index.js +0 -7
- package/dist/src/vite/plugins/index.d.ts +0 -3
- package/dist/src/vite/plugins/index.d.ts.map +0 -1
- package/dist/src/vite/plugins/index.js +0 -7
- package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts +0 -8
- package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts.map +0 -1
- package/dist/src/vite/plugins/third-party-css-inject/index.d.ts +0 -4
- package/dist/src/vite/plugins/third-party-css-inject/index.d.ts.map +0 -1
- package/dist/src/vite/plugins/third-party-css-inject/index.js +0 -13
- package/dist/src/vite/plugins/third-party-css-inject/main.d.ts +0 -17
- package/dist/src/vite/plugins/third-party-css-inject/main.d.ts.map +0 -1
- package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts +0 -5
- package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts.map +0 -1
- /package/dist/{src → cjs}/executors/deploy/schema.json +0 -0
- /package/dist/{src → cjs}/executors/environments/schema.json +0 -0
- /package/dist/{src → cjs}/executors/publish/schema.json +0 -0
- /package/dist/{src → cjs}/executors/update-executors-file/schema.json +0 -0
- /package/dist/{src → cjs}/executors/vtex-link/schema.json +0 -0
package/dist/package.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nizza/devkit",
|
|
3
|
-
"version": "0.1.0-alpha.1",
|
|
4
|
-
"source": "src/index.ts",
|
|
5
|
-
"main": "./src/index.js",
|
|
6
|
-
"types": "dist/src/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"dependencies": {},
|
|
11
|
-
"executors": "./executors.json",
|
|
12
|
-
"type": "commonjs"
|
|
13
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type ExecutorResponse } from '../shared';
|
|
3
|
-
export interface ExecutorOptions {
|
|
4
|
-
s3BucketPath: string;
|
|
5
|
-
cloudFrontDistributionId: string;
|
|
6
|
-
cloudFrontInvalidationPaths: string[];
|
|
7
|
-
buildTarget: string;
|
|
8
|
-
skipBuild?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export default function deployExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
11
|
-
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../../src/executors/deploy/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAOnB,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,EAAE,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAA8B,cAAc,CAC1C,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAyB3B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return deployExecutor;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _shared = require("../shared");
|
|
12
|
-
const _helpers = require("./helpers");
|
|
13
|
-
async function deployExecutor(opts, ctx) {
|
|
14
|
-
try {
|
|
15
|
-
const { root, name } = (0, _shared.getProjectConfig)(ctx);
|
|
16
|
-
const { s3BucketPath, cloudFrontDistributionId, cloudFrontInvalidationPaths, skipBuild = false } = opts;
|
|
17
|
-
const buildTarget = `${name}:${opts.buildTarget}`;
|
|
18
|
-
if (!skipBuild) await (0, _shared.runCommand)(`nx run ${buildTarget}`);
|
|
19
|
-
await (0, _helpers.cleanS3Bucket)(s3BucketPath);
|
|
20
|
-
await (0, _helpers.copyAssetsToS3)(s3BucketPath, root);
|
|
21
|
-
await (0, _helpers.createCloudFrontInvalidation)(cloudFrontDistributionId, cloudFrontInvalidationPaths);
|
|
22
|
-
const now = new Date().toLocaleString();
|
|
23
|
-
return (0, _shared.ok)(`✨ Build completed successfully on ${now}`);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
return (0, _shared.err)(error, '❌ Error when executing deploy command');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function cleanS3Bucket(s3BucketPath: string): Promise<void>;
|
|
2
|
-
export declare function copyAssetsToS3(s3BucketPath: string, projectRoot: string): Promise<void>;
|
|
3
|
-
export declare function createCloudFrontInvalidation(distributionId: string, invalidationPaths: string[]): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/executors/deploy/helpers.ts"],"names":[],"mappings":"AAGA,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIvE;AAED,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,wBAAsB,4BAA4B,CAChD,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
cleanS3Bucket: function() {
|
|
13
|
-
return cleanS3Bucket;
|
|
14
|
-
},
|
|
15
|
-
copyAssetsToS3: function() {
|
|
16
|
-
return copyAssetsToS3;
|
|
17
|
-
},
|
|
18
|
-
createCloudFrontInvalidation: function() {
|
|
19
|
-
return createCloudFrontInvalidation;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _devkit = require("@nx/devkit");
|
|
23
|
-
const _shared = require("../shared");
|
|
24
|
-
async function cleanS3Bucket(s3BucketPath) {
|
|
25
|
-
_devkit.logger.info('🧹 Cleaning S3 bucket...');
|
|
26
|
-
await (0, _shared.runCommand)(`aws s3 rm ${s3BucketPath} --recursive`);
|
|
27
|
-
_devkit.logger.info('✅ S3 bucket cleared.');
|
|
28
|
-
}
|
|
29
|
-
async function copyAssetsToS3(s3BucketPath, projectRoot) {
|
|
30
|
-
_devkit.logger.info('📦 Copying assets to S3 bucket...');
|
|
31
|
-
await (0, _shared.runCommand)(`aws s3 cp ${projectRoot}/dist ${s3BucketPath} --recursive`);
|
|
32
|
-
_devkit.logger.info('🚚 Assets files copied.');
|
|
33
|
-
}
|
|
34
|
-
async function createCloudFrontInvalidation(distributionId, invalidationPaths) {
|
|
35
|
-
const pathsString = invalidationPaths.map((path)=>`"${path}"`).join(' ');
|
|
36
|
-
const command = `aws cloudfront create-invalidation --distribution-id ${distributionId} --paths ${pathsString}`;
|
|
37
|
-
_devkit.logger.info('🔃 Creating invalidation for CloudFront...');
|
|
38
|
-
await (0, _shared.runCommand)(command);
|
|
39
|
-
_devkit.logger.info('🔄 CloudFront invalidation created.');
|
|
40
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type ExecutorResponse } from '../shared';
|
|
3
|
-
export interface ExecutorOptions {
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* The executor function to create environment files.
|
|
7
|
-
* Ensures that the directory for the environment files exists and creates the files
|
|
8
|
-
* if they do not exist already. Files created are 'environment.ts', 'environment.prod.ts',
|
|
9
|
-
* and 'environment.staging.ts'.
|
|
10
|
-
*
|
|
11
|
-
* @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
|
|
12
|
-
* @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
|
|
13
|
-
* @returns {Promise<ExecutorResponse>} The result object with a success or error status.
|
|
14
|
-
*/
|
|
15
|
-
export default function runExecutor(_opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
16
|
-
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../../src/executors/environments/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAqB7E,MAAM,WAAW,eAAe;CAAG;AAEnC;;;;;;;;;GASG;AACH,wBAA8B,WAAW,CACvC,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAiB3B"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, /**
|
|
6
|
-
* The executor function to create environment files.
|
|
7
|
-
* Ensures that the directory for the environment files exists and creates the files
|
|
8
|
-
* if they do not exist already. Files created are 'environment.ts', 'environment.prod.ts',
|
|
9
|
-
* and 'environment.staging.ts'.
|
|
10
|
-
*
|
|
11
|
-
* @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
|
|
12
|
-
* @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
|
|
13
|
-
* @returns {Promise<ExecutorResponse>} The result object with a success or error status.
|
|
14
|
-
*/ "default", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function() {
|
|
17
|
-
return runExecutor;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const _path = require("path");
|
|
21
|
-
const _shared = require("../shared");
|
|
22
|
-
const _helpers = require("./helpers");
|
|
23
|
-
const ENV_DIR = 'src/environments';
|
|
24
|
-
const ENV_DEV_FILE = 'environment.ts';
|
|
25
|
-
const ENV_LOCAL_FILE = 'environment.local.ts';
|
|
26
|
-
const ENV_PROD_FILE = 'environment.prod.ts';
|
|
27
|
-
const ENV_STAGING_FILE = 'environment.staging.ts';
|
|
28
|
-
const environmentFiles = [
|
|
29
|
-
ENV_DEV_FILE,
|
|
30
|
-
ENV_LOCAL_FILE,
|
|
31
|
-
ENV_PROD_FILE,
|
|
32
|
-
ENV_STAGING_FILE
|
|
33
|
-
];
|
|
34
|
-
async function runExecutor(_opts, ctx) {
|
|
35
|
-
try {
|
|
36
|
-
const projectConfig = (0, _shared.getProjectConfig)(ctx);
|
|
37
|
-
const environmentsDir = (0, _path.join)(projectConfig.root, ENV_DIR);
|
|
38
|
-
await (0, _helpers.ensureDirectoryExists)(environmentsDir);
|
|
39
|
-
for (const envFileName of environmentFiles){
|
|
40
|
-
const { key, path } = getEnvPath(envFileName);
|
|
41
|
-
const content = await (0, _helpers.createEnvironmentFileContent)(path);
|
|
42
|
-
await (0, _helpers.writeFilesIfNotExist)(environmentsDir, {
|
|
43
|
-
[key]: content
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return (0, _shared.ok)();
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return (0, _shared.err)(error, `Failed to create environment files:`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function getEnvPath(fileName) {
|
|
52
|
-
const isLocal = fileName.includes('.local');
|
|
53
|
-
const baseFileName = isLocal ? ENV_DEV_FILE : fileName;
|
|
54
|
-
const key = isLocal ? ENV_LOCAL_FILE : fileName;
|
|
55
|
-
return {
|
|
56
|
-
key,
|
|
57
|
-
path: `@nizza/core/envs/${baseFileName.replace('.ts', '')}`
|
|
58
|
-
};
|
|
59
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates the content for an environment file based on the core environment path.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} coreEnvPath - The path to the core environment file.
|
|
5
|
-
* @returns {string} The content of the environment file.
|
|
6
|
-
*/
|
|
7
|
-
export declare function createEnvironmentFileContent(coreEnvPath: string): Promise<string>;
|
|
8
|
-
/**
|
|
9
|
-
* Ensures that the given directory exists, creating it if it does not.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} dir - The path to the directory to check/create.
|
|
12
|
-
*/
|
|
13
|
-
export declare function ensureDirectoryExists(dir: string): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Writes environment files to the given base path if they do not already exist.
|
|
16
|
-
*
|
|
17
|
-
* @param {string} basePath - The base directory where the files should be written.
|
|
18
|
-
* @param {Record<string, string>} files - An object containing filenames and their respective content.
|
|
19
|
-
*/
|
|
20
|
-
export declare function writeFilesIfNotExist(basePath: string, files: Record<string, string>): Promise<void>;
|
|
21
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/executors/environments/helpers.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAStE;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
createEnvironmentFileContent: function() {
|
|
13
|
-
return createEnvironmentFileContent;
|
|
14
|
-
},
|
|
15
|
-
ensureDirectoryExists: function() {
|
|
16
|
-
return ensureDirectoryExists;
|
|
17
|
-
},
|
|
18
|
-
writeFilesIfNotExist: function() {
|
|
19
|
-
return writeFilesIfNotExist;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _fs = require("fs");
|
|
23
|
-
const _path = require("path");
|
|
24
|
-
const _devkit = require("@nx/devkit");
|
|
25
|
-
const { mkdir, writeFile, access } = _fs.promises;
|
|
26
|
-
async function createEnvironmentFileContent(coreEnvPath) {
|
|
27
|
-
return `
|
|
28
|
-
import { Environment } from '@nizza/core';
|
|
29
|
-
import coreEnvs from '${coreEnvPath}';
|
|
30
|
-
|
|
31
|
-
const config = {
|
|
32
|
-
...coreEnvs,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const environment: Environment<typeof config> = config;
|
|
36
|
-
export default environment;
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
async function ensureDirectoryExists(dir) {
|
|
40
|
-
try {
|
|
41
|
-
await access(dir);
|
|
42
|
-
_devkit.logger.info('✅ Directory exists.');
|
|
43
|
-
} catch {
|
|
44
|
-
_devkit.logger.info('📁 Directory does not exist. Creating...');
|
|
45
|
-
await mkdir(dir, {
|
|
46
|
-
recursive: true
|
|
47
|
-
});
|
|
48
|
-
_devkit.logger.info('📁 Directory created.');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async function writeFilesIfNotExist(basePath, files) {
|
|
52
|
-
await Promise.all(Object.entries(files).map(async ([filename, content])=>{
|
|
53
|
-
const filePath = (0, _path.join)(basePath, filename);
|
|
54
|
-
try {
|
|
55
|
-
await access(filePath);
|
|
56
|
-
_devkit.logger.info(`✅ The file "${filename}" already exists.`);
|
|
57
|
-
} catch {
|
|
58
|
-
_devkit.logger.warn(`📝 The file "${filename}" does not exist. Creating...`);
|
|
59
|
-
await writeFile(filePath, content);
|
|
60
|
-
_devkit.logger.info(`🎉 The file "${filename}" has been created.`);
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type ExecutorResponse } from '../shared';
|
|
3
|
-
export interface ExecutorOptions {
|
|
4
|
-
tag: string;
|
|
5
|
-
dryRun?: boolean;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* This is a minimal script to publish package to "npm".
|
|
9
|
-
* Need to authenticate with NPM before running this script.
|
|
10
|
-
*/
|
|
11
|
-
export default function runExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
12
|
-
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../../src/executors/publish/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAA8B,WAAW,CACvC,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA8D3B"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, /**
|
|
6
|
-
* This is a minimal script to publish package to "npm".
|
|
7
|
-
* Need to authenticate with NPM before running this script.
|
|
8
|
-
*/ "default", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function() {
|
|
11
|
-
return runExecutor;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
15
|
-
const _devkit = require("@nx/devkit");
|
|
16
|
-
const _semver = /*#__PURE__*/ _interop_require_default._(require("semver"));
|
|
17
|
-
const _shared = require("../../shared");
|
|
18
|
-
const _shared1 = require("../shared");
|
|
19
|
-
const _helpers = require("./helpers");
|
|
20
|
-
async function runExecutor(opts, ctx) {
|
|
21
|
-
try {
|
|
22
|
-
const { tag, dryRun: isDryRun } = opts;
|
|
23
|
-
const { root: projectRoot } = (0, _shared1.getProjectConfig)(ctx);
|
|
24
|
-
// Read the package.json file and extract the name and version.
|
|
25
|
-
const packageJson = (0, _shared.getPkgJson)(projectRoot);
|
|
26
|
-
const { name: packageName, version: packageVersion } = packageJson;
|
|
27
|
-
// Check if the package has been previously published and get the published version.
|
|
28
|
-
const { publishedVersion, isFirstVersion } = await (0, _helpers.checkPublishedVersion)(packageName);
|
|
29
|
-
let greaterThanTagVersion, greaterThanLatestVersion;
|
|
30
|
-
if (!isFirstVersion) {
|
|
31
|
-
// Check if the package version is greater than the latest published version for the specified tag.
|
|
32
|
-
greaterThanTagVersion = publishedVersion?.[tag] ? _semver.default.gt(packageVersion, publishedVersion?.[tag]) : true;
|
|
33
|
-
// Check if the package version is greater than the latest published version.
|
|
34
|
-
greaterThanLatestVersion = _semver.default.gt(packageVersion, publishedVersion.latest);
|
|
35
|
-
console.log(`🔎 package.json version: ${packageVersion}`);
|
|
36
|
-
console.log('🔺 published versions:');
|
|
37
|
-
Object.entries(publishedVersion).forEach(([k, v])=>console.log(` * ${k}: ${v}`));
|
|
38
|
-
console.log('\n');
|
|
39
|
-
}
|
|
40
|
-
// Publish the package if it's the first version or if it's a new version.
|
|
41
|
-
const needsPublish = isFirstVersion || greaterThanLatestVersion && greaterThanTagVersion;
|
|
42
|
-
if (needsPublish) {
|
|
43
|
-
const dryRun = isDryRun ? '--dry-run' : '';
|
|
44
|
-
const commandToPublish = `pnpm publish --access public --tag ${tag} --no-git-checks ${dryRun}`;
|
|
45
|
-
isDryRun && _devkit.logger.info('👀 Skip publish (dry run) \n');
|
|
46
|
-
_devkit.logger.info(`${commandToPublish} \n`);
|
|
47
|
-
// Execute the command to publish the package.
|
|
48
|
-
process.chdir(projectRoot);
|
|
49
|
-
await (0, _shared1.runCommand)(commandToPublish);
|
|
50
|
-
_devkit.logger.info(`\n🚀 Successfully published ${packageName}@${packageVersion}`);
|
|
51
|
-
} else {
|
|
52
|
-
_devkit.logger.warn(`👻 Package version "${packageVersion}" is invalid.`);
|
|
53
|
-
}
|
|
54
|
-
return (0, _shared1.ok)();
|
|
55
|
-
} catch (error) {
|
|
56
|
-
return (0, _shared1.err)(error, '❌ Error when publishing the package');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retrieves the version of a published package with a given name and tag.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} packageName The name of the package to retrieve the version for.
|
|
5
|
-
* @param {string} tag The tag to retrieve the version for.
|
|
6
|
-
* @returns The version of the package as a string or an object containing versions for each tag.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getPublishedPackageVersion(packageName: string, tag?: string): Promise<any>;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if a package with the given name is already published and returns its version.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} packageName The name of the package to check for.
|
|
13
|
-
* @returns An object containing the published versions of the package and a flag indicating if it is the first version.
|
|
14
|
-
*/
|
|
15
|
-
export declare function checkPublishedVersion(packageName: string): Promise<{
|
|
16
|
-
publishedVersion: any;
|
|
17
|
-
isFirstVersion: boolean;
|
|
18
|
-
}>;
|
|
19
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/executors/publish/helpers.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,GAAG,CAAC,EAAE,MAAM,gBAab;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM;;;GAmB9D"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
checkPublishedVersion: function() {
|
|
13
|
-
return checkPublishedVersion;
|
|
14
|
-
},
|
|
15
|
-
getPublishedPackageVersion: function() {
|
|
16
|
-
return getPublishedPackageVersion;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _devkit = require("@nx/devkit");
|
|
20
|
-
const _child_process = require("child_process");
|
|
21
|
-
const _util = require("util");
|
|
22
|
-
const execAsync = (0, _util.promisify)(_child_process.exec);
|
|
23
|
-
async function getPublishedPackageVersion(packageName, tag) {
|
|
24
|
-
const withTag = tag ? `.${tag}` : ' --json';
|
|
25
|
-
const command = `npm view ${packageName} dist-tags${withTag}`;
|
|
26
|
-
const { stdout, stderr } = await execAsync(command);
|
|
27
|
-
if (stderr) {
|
|
28
|
-
_devkit.logger.error(stderr.trim());
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
const published = stdout.trim();
|
|
32
|
-
return tag ? published : JSON.parse(published);
|
|
33
|
-
}
|
|
34
|
-
async function checkPublishedVersion(packageName) {
|
|
35
|
-
let publishedVersion;
|
|
36
|
-
let isFirstVersion = false;
|
|
37
|
-
try {
|
|
38
|
-
publishedVersion = await getPublishedPackageVersion(packageName);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
if (err?.message.includes('code E404')) {
|
|
41
|
-
isFirstVersion = true;
|
|
42
|
-
_devkit.logger.info(`🏁 This is the first version of "${packageName}" package. \n`);
|
|
43
|
-
} else {
|
|
44
|
-
_devkit.logger.error('❌ Error when checking the last published versions \n');
|
|
45
|
-
throw err;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
publishedVersion,
|
|
50
|
-
isFirstVersion
|
|
51
|
-
};
|
|
52
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/executors/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/executors/shared/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type ExecutorContext, type ProjectConfiguration } from '@nx/devkit';
|
|
2
|
-
import type { ExecutorResponse } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Indicates a successful executor operation.
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [message] - Optional message to log for the success case.
|
|
7
|
-
* @returns {ExecutorResponse} - An object representing a successful operation.
|
|
8
|
-
*/
|
|
9
|
-
export declare function ok(message?: string): ExecutorResponse;
|
|
10
|
-
/**
|
|
11
|
-
* Indicates a failed executor operation.
|
|
12
|
-
*
|
|
13
|
-
* @param {string | Error | unknown} [err] - An optional error object or message indicating the nature of the failure.
|
|
14
|
-
* @param {string} [message] - An optional message to log for the error case. If not provided, a default error message is logged.
|
|
15
|
-
* @returns {ExecutorResponse} - An object representing a failed operation.
|
|
16
|
-
*/
|
|
17
|
-
export declare function err(err?: string | Error | unknown, message?: string): ExecutorResponse;
|
|
18
|
-
/**
|
|
19
|
-
* Generates a random alphanumeric identifier of a specified length.
|
|
20
|
-
*
|
|
21
|
-
* @param {number} [length=8] - The length of the identifier to generate. Defaults to 8 if not specified.
|
|
22
|
-
* @returns {string} - A string representing a unique identifier.
|
|
23
|
-
*/
|
|
24
|
-
export declare function shortId(length?: number): string;
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves the project configuration for the current execution context.
|
|
27
|
-
*
|
|
28
|
-
* @param {ExecutorContext} ctx - The execution context containing project information.
|
|
29
|
-
* @returns {ProjectConfiguration} - The configuration object for the current project.
|
|
30
|
-
* @throws {Error} If the project configuration is invalid or not found.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getProjectConfig(ctx: ExecutorContext): ProjectConfiguration;
|
|
33
|
-
export declare function runCommand(command: string): Promise<void>;
|
|
34
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/executors/shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAMhD;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAGrD;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CACjB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,EAC9B,OAAO,CAAC,EAAE,MAAM,GACf,gBAAgB,CAUlB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,SAAI,UAIjC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,oBAAoB,CAK3E;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/D"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
err: function() {
|
|
13
|
-
return err;
|
|
14
|
-
},
|
|
15
|
-
getProjectConfig: function() {
|
|
16
|
-
return getProjectConfig;
|
|
17
|
-
},
|
|
18
|
-
ok: function() {
|
|
19
|
-
return ok;
|
|
20
|
-
},
|
|
21
|
-
runCommand: function() {
|
|
22
|
-
return runCommand;
|
|
23
|
-
},
|
|
24
|
-
shortId: function() {
|
|
25
|
-
return shortId;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const _devkit = require("@nx/devkit");
|
|
29
|
-
const _crypto = require("crypto");
|
|
30
|
-
const _child_process = require("child_process");
|
|
31
|
-
const _util = require("util");
|
|
32
|
-
const execAsync = (0, _util.promisify)(_child_process.exec);
|
|
33
|
-
function ok(message) {
|
|
34
|
-
message && _devkit.logger.info(message);
|
|
35
|
-
return {
|
|
36
|
-
success: true
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function err(err, message) {
|
|
40
|
-
if (message) {
|
|
41
|
-
_devkit.logger.error(message);
|
|
42
|
-
} else {
|
|
43
|
-
_devkit.logger.error(`❌ an error occurred:`);
|
|
44
|
-
}
|
|
45
|
-
if (err) _devkit.logger.error(err);
|
|
46
|
-
return {
|
|
47
|
-
success: false
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function shortId(length = 8) {
|
|
51
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
52
|
-
return Array.from((0, _crypto.randomBytes)(length), (b)=>chars[b % chars.length]).join('');
|
|
53
|
-
}
|
|
54
|
-
function getProjectConfig(ctx) {
|
|
55
|
-
const projectName = ctx.projectName || '';
|
|
56
|
-
const projectConfig = ctx.projectsConfigurations?.projects?.[projectName];
|
|
57
|
-
if (!projectConfig) throw new Error('Invalid project configuration.');
|
|
58
|
-
return projectConfig;
|
|
59
|
-
}
|
|
60
|
-
async function runCommand(command) {
|
|
61
|
-
try {
|
|
62
|
-
const { stdout, stderr } = await execAsync(command);
|
|
63
|
-
if (stderr) {
|
|
64
|
-
_devkit.logger.error(`Error running command:`);
|
|
65
|
-
_devkit.logger.error(stderr);
|
|
66
|
-
throw new Error(stderr);
|
|
67
|
-
}
|
|
68
|
-
_devkit.logger.info(stdout);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
_devkit.logger.error(`Unexpected error running command:`);
|
|
71
|
-
_devkit.logger.error(error);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type ExecutorResponse } from '../shared';
|
|
3
|
-
import type { ExecutorOptions } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Executor function to update paths in the executors.json file.
|
|
6
|
-
*
|
|
7
|
-
* @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
|
|
8
|
-
* @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
|
|
9
|
-
* @returns {Promise<ExecutorResponse>} The result object with a success or error status.
|
|
10
|
-
*/
|
|
11
|
-
export default function runExecutor(_opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
12
|
-
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../../src/executors/update-executors-file/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAW,KAAK,gBAAgB,EAAoB,MAAM,WAAW,CAAC;AAE7E,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAI9D;;;;;;GAMG;AACH,wBAA8B,WAAW,CACvC,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA8B3B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, /**
|
|
6
|
-
* Executor function to update paths in the executors.json file.
|
|
7
|
-
*
|
|
8
|
-
* @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
|
|
9
|
-
* @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
|
|
10
|
-
* @returns {Promise<ExecutorResponse>} The result object with a success or error status.
|
|
11
|
-
*/ "default", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function() {
|
|
14
|
-
return runExecutor;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const _fs = require("fs");
|
|
18
|
-
const _path = require("path");
|
|
19
|
-
const _shared = require("../shared");
|
|
20
|
-
const _helpers = require("./helpers");
|
|
21
|
-
const { readFile } = _fs.promises;
|
|
22
|
-
async function runExecutor(_opts, ctx) {
|
|
23
|
-
try {
|
|
24
|
-
const projectConfig = (0, _shared.getProjectConfig)(ctx);
|
|
25
|
-
const rootDir = projectConfig.root;
|
|
26
|
-
const executorsFilePath = (0, _path.join)(rootDir, 'executors.json');
|
|
27
|
-
const distExecutorsFilePath = (0, _path.join)(rootDir, 'dist', 'executors.json');
|
|
28
|
-
const originalContent = JSON.parse(await readFile(executorsFilePath, 'utf8'));
|
|
29
|
-
// Update paths to point to './dist/' and add '.js'
|
|
30
|
-
const updatedExecutors = (0, _helpers.updateExecutorPaths)(originalContent.executors, false);
|
|
31
|
-
// Prepare the version for the dist folder by removing './dist/' from paths
|
|
32
|
-
const distExecutors = (0, _helpers.updateExecutorPaths)(updatedExecutors, true);
|
|
33
|
-
// Write both files asynchronously and in parallel
|
|
34
|
-
await Promise.all([
|
|
35
|
-
(0, _helpers.writeJsonFileAsync)(executorsFilePath, {
|
|
36
|
-
executors: updatedExecutors
|
|
37
|
-
}),
|
|
38
|
-
(0, _helpers.writeJsonFileAsync)(distExecutorsFilePath, {
|
|
39
|
-
executors: distExecutors
|
|
40
|
-
})
|
|
41
|
-
]);
|
|
42
|
-
return (0, _shared.ok)(`🚀 Executors updated successfully.`);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
return (0, _shared.err)(error, `❌ Error processing file: ${error}`);
|
|
45
|
-
}
|
|
46
|
-
}
|