@nizza/devkit 0.1.0-alpha.2 → 0.1.0-alpha.4
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/helpers.d.cts +4 -0
- package/dist/cjs/executors/deploy/index.cjs +22 -0
- package/dist/cjs/executors/deploy/index.d.cts +11 -0
- package/dist/cjs/executors/environments/helpers.cjs +63 -0
- package/dist/{src/executors/environments/helpers.d.ts → cjs/executors/environments/helpers.d.cts} +4 -4
- package/dist/cjs/executors/environments/index.cjs +54 -0
- package/dist/{src/executors/environments/executor.d.ts → cjs/executors/environments/index.d.cts} +5 -5
- package/dist/cjs/executors/publish/helpers.cjs +51 -0
- package/dist/{src/executors/publish/helpers.d.ts → cjs/executors/publish/helpers.d.cts} +3 -3
- package/dist/cjs/executors/publish/index.cjs +53 -0
- package/dist/cjs/executors/publish/index.d.cts +12 -0
- package/dist/cjs/executors/shared/utils.cjs +78 -0
- package/dist/cjs/executors/shared/utils.d.cts +34 -0
- package/dist/cjs/executors/update-executors-file/helpers.cjs +64 -0
- package/dist/cjs/executors/update-executors-file/helpers.d.cts +17 -0
- package/dist/cjs/executors/update-executors-file/index.cjs +41 -0
- package/dist/{src/executors/update-executors-file/executor.d.ts → cjs/executors/update-executors-file/index.d.cts} +5 -5
- package/dist/cjs/executors/vtex-link/constants.cjs +9 -0
- package/dist/cjs/executors/vtex-link/constants.d.cts +4 -0
- package/dist/cjs/executors/vtex-link/helpers.cjs +206 -0
- package/dist/{src/executors/vtex-link/helpers.d.ts → cjs/executors/vtex-link/helpers.d.cts} +15 -15
- package/dist/cjs/executors/vtex-link/index.cjs +30 -0
- package/dist/cjs/executors/vtex-link/index.d.cts +5 -0
- package/dist/cjs/index-0ce2daf7.d.ts +2 -0
- package/dist/cjs/index-17143e35.d.ts +2 -0
- package/dist/cjs/index-3080371d.d.ts +3 -0
- package/dist/cjs/index-f6330edc.d.ts +2 -0
- package/dist/cjs/index.cjs +59 -0
- package/dist/cjs/index.d.cts +10 -0
- package/dist/cjs/index.d.cts.map +1 -0
- package/dist/cjs/scripts/changeset-pre-mode.cjs +41 -0
- package/dist/cjs/scripts/changeset-pre-mode.d.cts +2 -0
- package/dist/cjs/shared/logger.cjs +98 -0
- package/dist/{src/logger.d.ts → cjs/shared/logger.d.cts} +5 -6
- package/dist/cjs/shared/utils.cjs +25 -0
- package/dist/{src/shared/utils.d.ts → cjs/shared/utils.d.cts} +2 -2
- package/dist/{src/executors/vtex-link/types.d.ts → cjs/types-1282e639.d.ts} +3 -3
- package/dist/cjs/types-7377dcc9.d.ts +4 -0
- package/dist/cjs/types-763439e4.d.ts +14 -0
- package/dist/cjs/vite/config-builder/configs/app.cjs +13 -0
- package/dist/cjs/vite/config-builder/configs/app.d.cts +4 -0
- package/dist/cjs/vite/config-builder/configs/base.cjs +57 -0
- package/dist/cjs/vite/config-builder/configs/base.d.cts +4 -0
- package/dist/cjs/vite/config-builder/configs/index.cjs +36 -0
- package/dist/cjs/vite/config-builder/configs/index.d.cts +7 -0
- package/dist/cjs/vite/config-builder/configs/lib.cjs +57 -0
- package/dist/cjs/vite/config-builder/configs/lib.d.cts +4 -0
- package/dist/cjs/vite/config-builder/configs/script.cjs +45 -0
- package/dist/cjs/vite/config-builder/configs/script.d.cts +4 -0
- package/dist/cjs/vite/config-builder/main.cjs +43 -0
- package/dist/cjs/vite/config-builder/main.d.cts +10 -0
- package/dist/cjs/vite/config-builder/plugins.cjs +95 -0
- package/dist/{src/vite/config-builder/plugins.d.ts → cjs/vite/config-builder/plugins.d.cts} +7 -7
- package/dist/cjs/vite/config-builder/shared/types.cjs +33 -0
- package/dist/{src/vite/config-builder/shared/types.d.ts → cjs/vite/config-builder/shared/types.d.cts} +17 -17
- package/dist/cjs/vite/config-builder/shared/utils/helpers.cjs +124 -0
- package/dist/{src/vite/config-builder/shared/utils/helpers.d.ts → cjs/vite/config-builder/shared/utils/helpers.d.cts} +10 -10
- package/dist/cjs/vite/config-builder/shared/utils/projectConfig.cjs +114 -0
- package/dist/{src/vite/config-builder/shared/utils/projectConfig.d.ts → cjs/vite/config-builder/shared/utils/projectConfig.d.cts} +8 -8
- package/dist/cjs/vite/config-builder/shared/utils/viteCommand.cjs +59 -0
- package/dist/{src/vite/config-builder/shared/utils/viteCommand.d.ts → cjs/vite/config-builder/shared/utils/viteCommand.d.cts} +4 -4
- package/dist/{src/vite/plugins/shadow-dom-inject-css/index.js → cjs/vite/plugins/shadow-dom-inject-css/index.cjs} +4 -19
- package/dist/cjs/vite/plugins/shadow-dom-inject-css/index.d.cts +7 -0
- package/dist/{src/vite/plugins/third-party-css-inject/main.js → cjs/vite/plugins/third-party-css-inject/main.cjs} +13 -14
- package/dist/cjs/vite/plugins/third-party-css-inject/main.d.cts +17 -0
- package/dist/{src/vite/plugins/third-party-css-inject/utils.js → cjs/vite/plugins/third-party-css-inject/utils.cjs} +8 -20
- package/dist/cjs/vite/plugins/third-party-css-inject/utils.d.cts +5 -0
- package/dist/esm/executors/deploy/helpers.d.mts +4 -0
- package/dist/esm/executors/deploy/helpers.mjs +22 -0
- package/dist/esm/executors/deploy/index.d.mts +11 -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.d.mts +21 -0
- package/dist/esm/executors/environments/helpers.mjs +59 -0
- package/dist/esm/executors/environments/index.d.mts +16 -0
- package/dist/{src/executors/environments/executor.js → esm/executors/environments/index.mjs} +23 -30
- package/dist/esm/executors/environments/schema.json +9 -0
- package/dist/esm/executors/publish/helpers.d.mts +19 -0
- package/dist/esm/executors/publish/helpers.mjs +48 -0
- package/dist/esm/executors/publish/index.d.mts +12 -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.d.mts +34 -0
- package/dist/esm/executors/shared/utils.mjs +72 -0
- package/dist/esm/executors/update-executors-file/helpers.d.mts +17 -0
- package/dist/esm/executors/update-executors-file/helpers.mjs +59 -0
- package/dist/esm/executors/update-executors-file/index.d.mts +12 -0
- package/dist/esm/executors/update-executors-file/index.mjs +39 -0
- package/dist/esm/executors/update-executors-file/schema.json +9 -0
- package/dist/esm/executors/vtex-link/constants.d.mts +4 -0
- package/dist/esm/executors/vtex-link/constants.mjs +5 -0
- package/dist/esm/executors/vtex-link/helpers.d.mts +77 -0
- package/dist/esm/executors/vtex-link/helpers.mjs +192 -0
- package/dist/esm/executors/vtex-link/index.d.mts +5 -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-0ce2daf7.d.ts +2 -0
- package/dist/esm/index-17143e35.d.ts +2 -0
- package/dist/esm/index-3080371d.d.ts +3 -0
- package/dist/esm/index-f6330edc.d.ts +2 -0
- package/dist/esm/index.d.mts +10 -0
- package/dist/esm/index.d.mts.map +1 -0
- package/dist/esm/index.mjs +13 -0
- package/dist/esm/scripts/changeset-pre-mode.d.mts +2 -0
- package/dist/esm/scripts/changeset-pre-mode.mjs +39 -0
- package/dist/esm/shared/logger.d.mts +33 -0
- package/dist/{src/logger.js → esm/shared/logger.mjs} +28 -39
- package/dist/esm/shared/utils.d.mts +11 -0
- package/dist/esm/shared/utils.mjs +23 -0
- package/dist/esm/types-1282e639.d.ts +12 -0
- package/dist/esm/types-7377dcc9.d.ts +4 -0
- package/dist/esm/types-763439e4.d.ts +14 -0
- package/dist/esm/vite/config-builder/configs/app.d.mts +4 -0
- package/dist/esm/vite/config-builder/configs/app.mjs +11 -0
- package/dist/esm/vite/config-builder/configs/base.d.mts +4 -0
- package/dist/{src/vite/config-builder/configs/base.js → esm/vite/config-builder/configs/base.mjs} +22 -22
- package/dist/esm/vite/config-builder/configs/index.d.mts +7 -0
- package/dist/esm/vite/config-builder/configs/index.mjs +30 -0
- package/dist/esm/vite/config-builder/configs/lib.d.mts +4 -0
- package/dist/{src/vite/config-builder/configs/lib.js → esm/vite/config-builder/configs/lib.mjs} +16 -18
- package/dist/esm/vite/config-builder/configs/script.d.mts +4 -0
- package/dist/esm/vite/config-builder/configs/script.mjs +43 -0
- package/dist/esm/vite/config-builder/main.d.mts +10 -0
- package/dist/esm/vite/config-builder/main.mjs +41 -0
- package/dist/esm/vite/config-builder/plugins.d.mts +30 -0
- package/dist/esm/vite/config-builder/plugins.mjs +89 -0
- package/dist/esm/vite/config-builder/shared/types.d.mts +155 -0
- package/dist/{src/vite/config-builder/shared/types.js → esm/vite/config-builder/shared/types.mjs} +2 -27
- package/dist/esm/vite/config-builder/shared/utils/helpers.d.mts +81 -0
- package/dist/esm/vite/config-builder/shared/utils/helpers.mjs +98 -0
- package/dist/esm/vite/config-builder/shared/utils/projectConfig.d.mts +60 -0
- package/dist/esm/vite/config-builder/shared/utils/projectConfig.mjs +109 -0
- package/dist/esm/vite/config-builder/shared/utils/viteCommand.d.mts +24 -0
- package/dist/esm/vite/config-builder/shared/utils/viteCommand.mjs +56 -0
- package/dist/esm/vite/plugins/shadow-dom-inject-css/index.d.mts +7 -0
- package/dist/esm/vite/plugins/shadow-dom-inject-css/index.mjs +27 -0
- package/dist/esm/vite/plugins/third-party-css-inject/main.d.mts +17 -0
- package/dist/esm/vite/plugins/third-party-css-inject/main.mjs +45 -0
- package/dist/esm/vite/plugins/third-party-css-inject/utils.d.mts +5 -0
- package/dist/esm/vite/plugins/third-party-css-inject/utils.mjs +97 -0
- package/dist/executors.json +29 -0
- package/package.json +37 -5
- 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.map +0 -1
- 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.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 -78
- 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.map +0 -1
- package/dist/src/executors/vtex-link/helpers.js +0 -187
- 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.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.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.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.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.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.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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SharedContext } from "../../types-1282e639.js";
|
|
2
|
+
/**
|
|
3
|
+
* Links the local package to the VTEX environment.
|
|
4
|
+
*
|
|
5
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
6
|
+
* @returns {Promise<void>} A promise that resolves when the package is linked or rejects on error.
|
|
7
|
+
*/
|
|
8
|
+
declare function vtexLink(ctx: SharedContext): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Updates the package.json file within the VTEX project to use the local version of the package.
|
|
11
|
+
*
|
|
12
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
13
|
+
* @param {string} packageName - The name of the package to link.
|
|
14
|
+
* @returns {Promise<void>} A promise that resolves when the package.json is updated.
|
|
15
|
+
*/
|
|
16
|
+
declare function changePackageJsonFromVtexProject(ctx: SharedContext, packageName: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Restores the original package.json from the backup created before modifications.
|
|
19
|
+
*
|
|
20
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
21
|
+
* @returns {Promise<void>} A promise that resolves when the package.json is restored.
|
|
22
|
+
*/
|
|
23
|
+
declare function restorePackageJsonFromVtexProject(ctx: SharedContext): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Renames the generated package file with a unique identifier.
|
|
26
|
+
*
|
|
27
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
28
|
+
* @returns {Promise<string>} A promise that resolves with the new name of the package.
|
|
29
|
+
*/
|
|
30
|
+
declare function renamePackage(ctx: SharedContext): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a pnpm package for uploading to VTEX.
|
|
33
|
+
*
|
|
34
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
35
|
+
* @returns {Promise<string>} A promise that resolves with the name of the created package.
|
|
36
|
+
*/
|
|
37
|
+
declare function createPackage(ctx: SharedContext): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Searches for and lists all outdated packages in the VTEX project directory.
|
|
40
|
+
*
|
|
41
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
42
|
+
* @returns {Promise<string[]>} A promise that resolves with a list of deprecated package names.
|
|
43
|
+
*/
|
|
44
|
+
declare function findLastPackages(ctx: SharedContext): Promise<string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Removes all outdated packages in the VTEX project directory.
|
|
47
|
+
*
|
|
48
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
49
|
+
* @returns {Promise<void>} A promise that resolves when the old packages are removed.
|
|
50
|
+
*/
|
|
51
|
+
declare function removeOldPackages(ctx: SharedContext): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Moves a package to the VTEX project directory.
|
|
54
|
+
*
|
|
55
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
56
|
+
* @param {string} packageName - The name of the package to move.
|
|
57
|
+
* @returns {Promise<void>} A promise that resolves when the package is moved successfully.
|
|
58
|
+
*/
|
|
59
|
+
declare function movePackage(ctx: SharedContext, packageName: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Builds the package, moves it to the VTEX project, and updates the project's package.json.
|
|
62
|
+
*
|
|
63
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
64
|
+
* @returns {Promise<void>} A promise that resolves when the build is complete.
|
|
65
|
+
*/
|
|
66
|
+
declare function buildPackage(ctx: SharedContext): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Cleans the VTEX project by removing old packages and restoring the original package.json.
|
|
69
|
+
*
|
|
70
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
71
|
+
* @returns {Promise<void>} A promise that resolves when the clean-up is complete.
|
|
72
|
+
*/
|
|
73
|
+
declare function clean(ctx: SharedContext): Promise<void>;
|
|
74
|
+
declare function validateEnvironment(): void;
|
|
75
|
+
declare function performRollback(sharedContext: SharedContext): Promise<import("../../index-f6330edc.js").ExecutorResponse>;
|
|
76
|
+
declare function buildAndLink(sharedContext: SharedContext, skipLink?: boolean): Promise<void>;
|
|
77
|
+
export { vtexLink, changePackageJsonFromVtexProject, restorePackageJsonFromVtexProject, renamePackage, createPackage, findLastPackages, removeOldPackages, movePackage, buildPackage, clean, validateEnvironment, performRollback, buildAndLink };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { logger } from '@nx/devkit';
|
|
2
|
+
import { exec, spawn } from 'child_process';
|
|
3
|
+
import { promises, existsSync } from 'fs';
|
|
4
|
+
import { join, resolve } from 'path';
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
import '../../shared/logger.mjs';
|
|
7
|
+
import { getPkgJson } from '../../shared/utils.mjs';
|
|
8
|
+
import { ok, shortId } from '../shared/utils.mjs';
|
|
9
|
+
import { VTEX_PROJECT_PATH, ERROR_LINKING_FLAG, SUCCESS_LINKING_FLAG } from './constants.mjs';
|
|
10
|
+
|
|
11
|
+
const execAsync = promisify(exec);
|
|
12
|
+
const getPkgJsonPath = (vtexProjectPath)=>resolve(vtexProjectPath, 'package.json');
|
|
13
|
+
/**
|
|
14
|
+
* Links the local package to the VTEX environment.
|
|
15
|
+
*
|
|
16
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
17
|
+
* @returns {Promise<void>} A promise that resolves when the package is linked or rejects on error.
|
|
18
|
+
*/ function vtexLink(ctx) {
|
|
19
|
+
const { vtexProjectPath } = ctx;
|
|
20
|
+
return new Promise((resolve, reject)=>{
|
|
21
|
+
logger.info('🔗 Linking package to VTEX...');
|
|
22
|
+
const link = spawn('vtex', [
|
|
23
|
+
'link',
|
|
24
|
+
'-u'
|
|
25
|
+
], {
|
|
26
|
+
cwd: vtexProjectPath,
|
|
27
|
+
detached: true
|
|
28
|
+
});
|
|
29
|
+
link.stdout.on('data', (chunk)=>{
|
|
30
|
+
const data = chunk.toString('utf8');
|
|
31
|
+
if (data.includes(ERROR_LINKING_FLAG)) {
|
|
32
|
+
reject('could not link package in VTEX');
|
|
33
|
+
}
|
|
34
|
+
if (data.includes(SUCCESS_LINKING_FLAG)) {
|
|
35
|
+
link.pid && process.kill(-link.pid);
|
|
36
|
+
setTimeout(()=>{
|
|
37
|
+
link.kill();
|
|
38
|
+
logger.info('✅ Successfully linked package to VTEX.');
|
|
39
|
+
}, 200);
|
|
40
|
+
resolve();
|
|
41
|
+
}
|
|
42
|
+
logger.info(data);
|
|
43
|
+
});
|
|
44
|
+
link.on('error', (error)=>reject(error.message));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Updates the package.json file within the VTEX project to use the local version of the package.
|
|
49
|
+
*
|
|
50
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
51
|
+
* @param {string} packageName - The name of the package to link.
|
|
52
|
+
* @returns {Promise<void>} A promise that resolves when the package.json is updated.
|
|
53
|
+
*/ async function changePackageJsonFromVtexProject(ctx, packageName) {
|
|
54
|
+
const { vtexProjectPath, projectName, packageOrg } = ctx;
|
|
55
|
+
const pkgJsonPath = getPkgJsonPath(vtexProjectPath);
|
|
56
|
+
// Make backup of package.json
|
|
57
|
+
await promises.copyFile(pkgJsonPath, join(vtexProjectPath, 'package.json.nxback'));
|
|
58
|
+
logger.info('🔃 Created package.json backup.');
|
|
59
|
+
// Find and edit value "@${packageOrg}/${projectName}" dependency
|
|
60
|
+
const packageJson = getPkgJson(vtexProjectPath);
|
|
61
|
+
const newPackageJson = {
|
|
62
|
+
...packageJson,
|
|
63
|
+
dependencies: {
|
|
64
|
+
...packageJson.dependencies,
|
|
65
|
+
[`@${packageOrg}/${projectName}`]: `file:./${packageName}`
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
await promises.unlink(pkgJsonPath);
|
|
69
|
+
await promises.writeFile(pkgJsonPath, JSON.stringify(newPackageJson, null, 2));
|
|
70
|
+
logger.info('📝 Updated package.json in VTEX project.');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Restores the original package.json from the backup created before modifications.
|
|
74
|
+
*
|
|
75
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
76
|
+
* @returns {Promise<void>} A promise that resolves when the package.json is restored.
|
|
77
|
+
*/ async function restorePackageJsonFromVtexProject(ctx) {
|
|
78
|
+
const { vtexProjectPath } = ctx;
|
|
79
|
+
const pkgJsonPath = getPkgJsonPath(vtexProjectPath);
|
|
80
|
+
const backupFile = resolve(vtexProjectPath, 'package.json.nxback');
|
|
81
|
+
if (!existsSync(backupFile)) return;
|
|
82
|
+
await promises.unlink(pkgJsonPath);
|
|
83
|
+
await promises.copyFile(backupFile, pkgJsonPath);
|
|
84
|
+
await promises.unlink(backupFile);
|
|
85
|
+
logger.info('🔄 Restored package.json in VTEX project.');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Renames the generated package file with a unique identifier.
|
|
89
|
+
*
|
|
90
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
91
|
+
* @returns {Promise<string>} A promise that resolves with the new name of the package.
|
|
92
|
+
*/ async function renamePackage(ctx) {
|
|
93
|
+
const { projectRoot, projectName, packageOrg } = ctx;
|
|
94
|
+
const packageJson = getPkgJson('./');
|
|
95
|
+
const oldName = `${packageOrg}-${projectName}-${packageJson.version}.tgz`;
|
|
96
|
+
const oldPath = join(projectRoot, oldName);
|
|
97
|
+
const newName = `${packageOrg}-${projectName}-${packageJson.version}-${shortId(8)}.tgz`;
|
|
98
|
+
const newPath = join(projectRoot, newName);
|
|
99
|
+
await promises.rename(oldPath, newPath);
|
|
100
|
+
logger.info(`🏷️ New package name: ${newName}`);
|
|
101
|
+
return newName;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a pnpm package for uploading to VTEX.
|
|
105
|
+
*
|
|
106
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
107
|
+
* @returns {Promise<string>} A promise that resolves with the name of the created package.
|
|
108
|
+
*/ async function createPackage(ctx) {
|
|
109
|
+
const command = 'pnpm pack';
|
|
110
|
+
const { stderr } = await execAsync(command);
|
|
111
|
+
if (stderr) logger.error(stderr);
|
|
112
|
+
logger.info('📦 Package generated successfully.');
|
|
113
|
+
return renamePackage(ctx);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Searches for and lists all outdated packages in the VTEX project directory.
|
|
117
|
+
*
|
|
118
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
119
|
+
* @returns {Promise<string[]>} A promise that resolves with a list of deprecated package names.
|
|
120
|
+
*/ async function findLastPackages(ctx) {
|
|
121
|
+
const { vtexProjectPath, projectName, packageOrg } = ctx;
|
|
122
|
+
const matchedFiles = [];
|
|
123
|
+
const files = await promises.readdir(vtexProjectPath);
|
|
124
|
+
for (const file of files){
|
|
125
|
+
const regex = new RegExp(`^${packageOrg}-${projectName}-.*$`);
|
|
126
|
+
if (regex.test(file)) {
|
|
127
|
+
matchedFiles.push(file);
|
|
128
|
+
logger.info(`🔍 Found deprecated package: ${file}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return matchedFiles;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Removes all outdated packages in the VTEX project directory.
|
|
135
|
+
*
|
|
136
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
137
|
+
* @returns {Promise<void>} A promise that resolves when the old packages are removed.
|
|
138
|
+
*/ async function removeOldPackages(ctx) {
|
|
139
|
+
const { vtexProjectPath } = ctx;
|
|
140
|
+
const files = await findLastPackages(ctx);
|
|
141
|
+
const toRemove = files.map((x)=>promises.unlink(resolve(vtexProjectPath, x)));
|
|
142
|
+
await Promise.all(toRemove);
|
|
143
|
+
logger.info('🗑️ Removed old packages in VTEX project.');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Moves a package to the VTEX project directory.
|
|
147
|
+
*
|
|
148
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
149
|
+
* @param {string} packageName - The name of the package to move.
|
|
150
|
+
* @returns {Promise<void>} A promise that resolves when the package is moved successfully.
|
|
151
|
+
*/ async function movePackage(ctx, packageName) {
|
|
152
|
+
const { vtexProjectPath } = ctx;
|
|
153
|
+
await promises.rename(resolve(packageName), join(vtexProjectPath, packageName));
|
|
154
|
+
logger.info(`🚚 Moved package "${packageName}" to VTEX project.`);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Builds the package, moves it to the VTEX project, and updates the project's package.json.
|
|
158
|
+
*
|
|
159
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
160
|
+
* @returns {Promise<void>} A promise that resolves when the build is complete.
|
|
161
|
+
*/ async function buildPackage(ctx) {
|
|
162
|
+
const packageName = await createPackage(ctx);
|
|
163
|
+
await Promise.all([
|
|
164
|
+
movePackage(ctx, packageName),
|
|
165
|
+
changePackageJsonFromVtexProject(ctx, packageName)
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Cleans the VTEX project by removing old packages and restoring the original package.json.
|
|
170
|
+
*
|
|
171
|
+
* @param {SharedContext} ctx - The shared context containing paths and configurations.
|
|
172
|
+
* @returns {Promise<void>} A promise that resolves when the clean-up is complete.
|
|
173
|
+
*/ async function clean(ctx) {
|
|
174
|
+
await Promise.all([
|
|
175
|
+
removeOldPackages(ctx),
|
|
176
|
+
restorePackageJsonFromVtexProject(ctx)
|
|
177
|
+
]);
|
|
178
|
+
}
|
|
179
|
+
function validateEnvironment() {
|
|
180
|
+
if (!VTEX_PROJECT_PATH) throw new Error('The NZ_VTEX_PROJECT environment variable is missing. Set it in the project root in a .env.local file.');
|
|
181
|
+
}
|
|
182
|
+
async function performRollback(sharedContext) {
|
|
183
|
+
await clean(sharedContext);
|
|
184
|
+
return ok();
|
|
185
|
+
}
|
|
186
|
+
async function buildAndLink(sharedContext, skipLink = false) {
|
|
187
|
+
await clean(sharedContext);
|
|
188
|
+
await buildPackage(sharedContext);
|
|
189
|
+
if (!skipLink) await vtexLink(sharedContext);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { buildAndLink, buildPackage, changePackageJsonFromVtexProject, clean, createPackage, findLastPackages, movePackage, performRollback, removeOldPackages, renamePackage, restorePackageJsonFromVtexProject, validateEnvironment, vtexLink };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { ExecutorResponse } from "../../index-f6330edc.js";
|
|
3
|
+
import { ExecutorOptions } from "../../types-1282e639.js";
|
|
4
|
+
declare function runExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
5
|
+
export { runExecutor as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { getProjectConfig, ok, err } from '../shared/utils.mjs';
|
|
3
|
+
import { validateEnvironment, performRollback, buildAndLink } from './helpers.mjs';
|
|
4
|
+
|
|
5
|
+
const VTEX_PROJECT_PATH = process.env.NZ_VTEX_PROJECT;
|
|
6
|
+
async function runExecutor(opts, ctx) {
|
|
7
|
+
try {
|
|
8
|
+
const { rollback, skipLink, packageOrg } = opts;
|
|
9
|
+
const projectName = ctx.projectName || '';
|
|
10
|
+
validateEnvironment();
|
|
11
|
+
const projectConfig = getProjectConfig(ctx);
|
|
12
|
+
const projectRoot = projectConfig.root;
|
|
13
|
+
const vtexProjectPath = resolve(VTEX_PROJECT_PATH, 'react');
|
|
14
|
+
const sharedContext = {
|
|
15
|
+
packageOrg,
|
|
16
|
+
projectRoot,
|
|
17
|
+
projectName,
|
|
18
|
+
vtexProjectPath
|
|
19
|
+
};
|
|
20
|
+
if (rollback) return await performRollback(sharedContext);
|
|
21
|
+
await buildAndLink(sharedContext, skipLink);
|
|
22
|
+
return ok();
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return err(error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { runExecutor as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "VtexLink executor",
|
|
5
|
+
"description": "",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"packageOrg": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Name of the npm organization in which the packages are published"
|
|
11
|
+
},
|
|
12
|
+
"rollback": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "Perform a rollback.",
|
|
15
|
+
"default": false
|
|
16
|
+
},
|
|
17
|
+
"skipLink": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Skip the linking step.",
|
|
20
|
+
"default": false
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": [],
|
|
24
|
+
"additionalProperties": true
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as deployExecutor } from "./executors/deploy/index.js";
|
|
2
|
+
export { default as environmentsExecutor } from "./executors/environments/index.js";
|
|
3
|
+
export { default as publishExecutor } from "./executors/publish/index.js";
|
|
4
|
+
export { default as updateExecutorsFileExecutor } from "./executors/update-executors-file/index.js";
|
|
5
|
+
export { default as vtexLinkExecutor } from "./executors/vtex-link/index.js";
|
|
6
|
+
export * from "./scripts/changeset-pre-mode.js";
|
|
7
|
+
export * from "./vite/config-builder/main.js";
|
|
8
|
+
export * from "./index-f6330edc.js";
|
|
9
|
+
export * from "./index-0ce2daf7.js";
|
|
10
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/executors/index.ts","../../src/scripts/index.ts","../../src/vite/config-builder/index.ts","../../src/vite/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as deployExecutor } from './executors/deploy/index.mjs';
|
|
2
|
+
export { default as environmentsExecutor } from './executors/environments/index.mjs';
|
|
3
|
+
export { default as publishExecutor } from './executors/publish/index.mjs';
|
|
4
|
+
export { default as updateExecutorsFileExecutor } from './executors/update-executors-file/index.mjs';
|
|
5
|
+
export { default as vtexLinkExecutor } from './executors/vtex-link/index.mjs';
|
|
6
|
+
export { main } from './scripts/changeset-pre-mode.mjs';
|
|
7
|
+
export { createConfigBuilder } from './vite/config-builder/main.mjs';
|
|
8
|
+
export { Flag, ProjectType, Stage, Target, ViteMode } from './vite/config-builder/shared/types.mjs';
|
|
9
|
+
export { chunkName, deepMerge, getNxTsConfigPaths, getPlugins, shortId, when } from './vite/config-builder/shared/utils/helpers.mjs';
|
|
10
|
+
export { getExternalDependencies, getInitials, initializeConfig, mergeConfigs } from './vite/config-builder/shared/utils/projectConfig.mjs';
|
|
11
|
+
export { getViteCmdFlags, getViteCommand } from './vite/config-builder/shared/utils/viteCommand.mjs';
|
|
12
|
+
export { thirdPartyCssInjectPlugin } from './vite/plugins/third-party-css-inject/main.mjs';
|
|
13
|
+
export { injectCssIntoShadowDom } from './vite/plugins/shadow-dom-inject-css/index.mjs';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { logger } from '@nx/devkit';
|
|
2
|
+
import { exec } from 'child_process';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
|
|
7
|
+
const execAsync = promisify(exec);
|
|
8
|
+
const changesetDir = resolve('.changeset');
|
|
9
|
+
const preJsonPath = resolve(changesetDir, 'pre.json');
|
|
10
|
+
let preJson;
|
|
11
|
+
async function main() {
|
|
12
|
+
try {
|
|
13
|
+
const data = await readFile(preJsonPath, 'utf8');
|
|
14
|
+
preJson = JSON.parse(data);
|
|
15
|
+
} catch {
|
|
16
|
+
preJson = {
|
|
17
|
+
mode: 'exit'
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Execute "version" command using @changeset/cli
|
|
21
|
+
try {
|
|
22
|
+
const { mode } = preJson;
|
|
23
|
+
if (mode === 'exit') {
|
|
24
|
+
const command = `pnpm changeset pre enter beta`;
|
|
25
|
+
const { stdout, stderr } = await execAsync(command);
|
|
26
|
+
logger.info(stdout);
|
|
27
|
+
logger.info(stderr);
|
|
28
|
+
logger.info(`🚀 Successfully enter prerelease mode`);
|
|
29
|
+
} else {
|
|
30
|
+
logger.info(`🚀 Prerelease mode has been previously entered`);
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
logger.error('❌ An error occurred!');
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
main();
|
|
38
|
+
|
|
39
|
+
export { main };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing the different log levels.
|
|
3
|
+
*/
|
|
4
|
+
declare enum LogLevel {
|
|
5
|
+
ERROR = 0,
|
|
6
|
+
WARN = 1,
|
|
7
|
+
INFO = 2,
|
|
8
|
+
DEBUG = 3
|
|
9
|
+
}
|
|
10
|
+
declare let currentLogLevel: LogLevel;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the log level for the logger.
|
|
13
|
+
* Only logs at this level and above will be displayed.
|
|
14
|
+
*
|
|
15
|
+
* @param {LogLevel} level - The log level to set.
|
|
16
|
+
* @example
|
|
17
|
+
* // Set log level to WARN
|
|
18
|
+
* setLogLevel(LogLevel.WARN);
|
|
19
|
+
*
|
|
20
|
+
* // Now only WARN and ERROR logs will be displayed
|
|
21
|
+
* logger.debug('Debug message'); // Will not be logged
|
|
22
|
+
* logger.info('Info message'); // Will not be logged
|
|
23
|
+
* logger.warn('Warn message'); // Will be logged
|
|
24
|
+
* logger.error('Error message'); // Will be logged
|
|
25
|
+
*/
|
|
26
|
+
declare const setLogLevel: (level: LogLevel) => void;
|
|
27
|
+
declare const logger: {
|
|
28
|
+
error: (message: string, ...rest: any[]) => void;
|
|
29
|
+
warn: (message: string, ...rest: any[]) => void;
|
|
30
|
+
info: (message: string, ...rest: any[]) => void;
|
|
31
|
+
debug: (message: string, ...rest: any[]) => void;
|
|
32
|
+
};
|
|
33
|
+
export { LogLevel, currentLogLevel, setLogLevel, logger };
|
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
LogLevel: function() {
|
|
13
|
-
return LogLevel;
|
|
14
|
-
},
|
|
15
|
-
currentLogLevel: function() {
|
|
16
|
-
return currentLogLevel;
|
|
17
|
-
},
|
|
18
|
-
default: function() {
|
|
19
|
-
return _default;
|
|
20
|
-
},
|
|
21
|
-
logger: function() {
|
|
22
|
-
return logger;
|
|
23
|
-
},
|
|
24
|
-
setLogLevel: function() {
|
|
25
|
-
return setLogLevel;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
29
|
-
const _chalk = /*#__PURE__*/ _interop_require_default._(require("chalk"));
|
|
30
|
-
const _ramda = require("ramda");
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { pipe, map, join } from 'ramda';
|
|
3
|
+
|
|
31
4
|
var LogLevel;
|
|
32
5
|
(function(LogLevel) {
|
|
33
6
|
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
|
|
@@ -35,6 +8,7 @@ var LogLevel;
|
|
|
35
8
|
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
36
9
|
LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
|
|
37
10
|
})(LogLevel || (LogLevel = {}));
|
|
11
|
+
// Default log level
|
|
38
12
|
let currentLogLevel = 2;
|
|
39
13
|
/**
|
|
40
14
|
* Object mapping log levels to console log functions.
|
|
@@ -51,15 +25,29 @@ let currentLogLevel = 2;
|
|
|
51
25
|
*
|
|
52
26
|
* @constant {Object} colorFunctions
|
|
53
27
|
*/ const colorFunctions = {
|
|
54
|
-
[0]:
|
|
55
|
-
[1]:
|
|
56
|
-
[2]:
|
|
57
|
-
[3]:
|
|
28
|
+
[0]: chalk.red,
|
|
29
|
+
[1]: chalk.yellow,
|
|
30
|
+
[2]: chalk.blue,
|
|
31
|
+
[3]: chalk.magenta
|
|
58
32
|
};
|
|
59
33
|
const getLogLevelKey = (value)=>{
|
|
60
34
|
return Object.keys(LogLevel).find((key)=>LogLevel[key] === value);
|
|
61
35
|
};
|
|
62
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Sets the log level for the logger.
|
|
38
|
+
* Only logs at this level and above will be displayed.
|
|
39
|
+
*
|
|
40
|
+
* @param {LogLevel} level - The log level to set.
|
|
41
|
+
* @example
|
|
42
|
+
* // Set log level to WARN
|
|
43
|
+
* setLogLevel(LogLevel.WARN);
|
|
44
|
+
*
|
|
45
|
+
* // Now only WARN and ERROR logs will be displayed
|
|
46
|
+
* logger.debug('Debug message'); // Will not be logged
|
|
47
|
+
* logger.info('Info message'); // Will not be logged
|
|
48
|
+
* logger.warn('Warn message'); // Will be logged
|
|
49
|
+
* logger.error('Error message'); // Will be logged
|
|
50
|
+
*/ const setLogLevel = (level)=>{
|
|
63
51
|
currentLogLevel = level;
|
|
64
52
|
};
|
|
65
53
|
/**
|
|
@@ -68,7 +56,7 @@ const setLogLevel = (level)=>{
|
|
|
68
56
|
*
|
|
69
57
|
* @param {any[]} args - The arguments to process.
|
|
70
58
|
* @returns {string} - The processed string.
|
|
71
|
-
*/ const processArgs =
|
|
59
|
+
*/ const processArgs = pipe(map((arg)=>JSON.stringify(arg, null, 2)), join('\n'));
|
|
72
60
|
/**
|
|
73
61
|
* Formats the log message with a timestamp, log level, and any additional variables.
|
|
74
62
|
*
|
|
@@ -89,8 +77,8 @@ const setLogLevel = (level)=>{
|
|
|
89
77
|
* @returns - The log function.
|
|
90
78
|
*/ const log = (level)=>(message, ...rest)=>{
|
|
91
79
|
if (level > currentLogLevel) return; // Skip logging if level is below the current log level
|
|
92
|
-
const pipeline =
|
|
93
|
-
const errPipeline =
|
|
80
|
+
const pipeline = pipe(()=>formatMessage(level, message, ...rest), colorFunctions[level], logFunctions[level]);
|
|
81
|
+
const errPipeline = pipe((err)=>`Failed to log message: ${err.message}`, colorFunctions[0], logFunctions[0]);
|
|
94
82
|
try {
|
|
95
83
|
pipeline();
|
|
96
84
|
} catch (err) {
|
|
@@ -103,4 +91,5 @@ const logger = {
|
|
|
103
91
|
info: log(2),
|
|
104
92
|
debug: log(3)
|
|
105
93
|
};
|
|
106
|
-
|
|
94
|
+
|
|
95
|
+
export { LogLevel, currentLogLevel, logger, setLogLevel };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads and parses the package.json file from the given project path.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} projectPath - The path to the project.
|
|
5
|
+
* @returns {Record<string, any>} - The parsed package.json data.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const pkgJsonData = getPkgJson('/path/to/project');
|
|
9
|
+
*/
|
|
10
|
+
declare const getPkgJson: (projectPath: string) => Record<string, any>;
|
|
11
|
+
export { getPkgJson };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { logger } from '@nx/devkit';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reads and parses the package.json file from the given project path.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} projectPath - The path to the project.
|
|
9
|
+
* @returns {Record<string, any>} - The parsed package.json data.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const pkgJsonData = getPkgJson('/path/to/project');
|
|
13
|
+
*/ const getPkgJson = (projectPath)=>{
|
|
14
|
+
try {
|
|
15
|
+
const data = readFileSync(resolve(projectPath, './package.json'), 'utf-8');
|
|
16
|
+
return JSON.parse(data);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
logger.error('Error reading or parsing package.json');
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { getPkgJson };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface SharedContext {
|
|
2
|
+
vtexProjectPath: string;
|
|
3
|
+
projectRoot: string;
|
|
4
|
+
projectName: string;
|
|
5
|
+
packageOrg: string;
|
|
6
|
+
}
|
|
7
|
+
interface ExecutorOptions {
|
|
8
|
+
packageOrg: string;
|
|
9
|
+
rollback?: boolean;
|
|
10
|
+
skipLink?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export { SharedContext, ExecutorOptions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ExecutorOptions {
|
|
2
|
+
}
|
|
3
|
+
interface ExecutorConfig {
|
|
4
|
+
implementation: string;
|
|
5
|
+
schema: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
interface Executors {
|
|
9
|
+
[executorName: string]: ExecutorConfig;
|
|
10
|
+
}
|
|
11
|
+
interface ExecutorsFile {
|
|
12
|
+
executors: Executors;
|
|
13
|
+
}
|
|
14
|
+
export { ExecutorOptions, ExecutorConfig, Executors, ExecutorsFile };
|