@nizza/devkit 0.1.0-alpha.0 → 0.1.0-alpha.10
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/README.md +2 -6
- 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 +62 -0
- package/dist/{src/executors/environments/helpers.d.ts → cjs/executors/environments/helpers.d.cts} +9 -5
- package/dist/cjs/executors/environments/index.cjs +60 -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 +67 -0
- package/dist/cjs/executors/shared/utils.d.cts +27 -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 +38 -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 +71 -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/scripts/index.cjs +7 -0
- package/dist/cjs/scripts/index.d.cts +1 -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 +64 -0
- package/dist/cjs/shared/utils.d.cts +19 -0
- 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 +58 -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 +46 -0
- package/dist/cjs/vite/config-builder/configs/script.d.cts +4 -0
- package/dist/cjs/vite/config-builder/main.cjs +42 -0
- package/dist/cjs/vite/config-builder/main.d.cts +10 -0
- package/dist/cjs/vite/config-builder/plugins.cjs +93 -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 +115 -0
- package/dist/{src/vite/config-builder/shared/utils/helpers.d.ts → cjs/vite/config-builder/shared/utils/helpers.d.cts} +9 -19
- 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 +25 -0
- package/dist/esm/executors/environments/helpers.mjs +58 -0
- package/dist/esm/executors/environments/index.d.mts +16 -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.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 +27 -0
- package/dist/esm/executors/shared/utils.mjs +62 -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 +36 -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 +14 -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/scripts/index.d.mts +1 -0
- package/dist/esm/scripts/index.mjs +1 -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 +19 -0
- package/dist/esm/shared/utils.mjs +60 -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} +23 -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 +44 -0
- package/dist/esm/vite/config-builder/main.d.mts +10 -0
- package/dist/esm/vite/config-builder/main.mjs +40 -0
- package/dist/esm/vite/config-builder/plugins.d.mts +30 -0
- package/dist/esm/vite/config-builder/plugins.mjs +87 -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 +71 -0
- package/dist/esm/vite/config-builder/shared/utils/helpers.mjs +90 -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/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.map +0 -1
- package/dist/src/executors/environments/executor.js +0 -59
- 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 -57
- 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.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 +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.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,155 @@
|
|
|
1
|
+
import { ConfigEnv, LibraryOptions, UserConfig } from 'vite';
|
|
2
|
+
import { LogLevel } from "../../../index-17143e35.js";
|
|
3
|
+
declare enum ViteMode {
|
|
4
|
+
PROD = "production",
|
|
5
|
+
DEV = "development"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Project stages, it coincides with the target configurations of the project.json of NX.
|
|
9
|
+
* @readonly
|
|
10
|
+
* @enum {string}
|
|
11
|
+
*/
|
|
12
|
+
declare enum Stage {
|
|
13
|
+
PROD = "prod",
|
|
14
|
+
DEV = "dev",
|
|
15
|
+
STAGING = "staging",
|
|
16
|
+
LOCAL = "local"
|
|
17
|
+
}
|
|
18
|
+
declare enum ProjectType {
|
|
19
|
+
APP = "app",
|
|
20
|
+
LIB = "lib",
|
|
21
|
+
SCRIPT = "script"
|
|
22
|
+
}
|
|
23
|
+
declare enum Flag {
|
|
24
|
+
SOURCEMAP = "source-maps",
|
|
25
|
+
ANALYZE = "analyze",
|
|
26
|
+
VERBOSE = "verbose",
|
|
27
|
+
VERBOSE_ALIAS = "v"
|
|
28
|
+
}
|
|
29
|
+
declare enum Target {
|
|
30
|
+
BUILD = "build",
|
|
31
|
+
PREVIEW = "preview",
|
|
32
|
+
SERVE = "serve"
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Vite Environment.
|
|
36
|
+
*
|
|
37
|
+
* @property {ViteMode} mode - Vite mode.
|
|
38
|
+
*/
|
|
39
|
+
type ViteEnv = ConfigEnv & {
|
|
40
|
+
mode: ViteMode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Externalizing libraries.
|
|
44
|
+
*
|
|
45
|
+
* @property {boolean} default - React externalizes and other common dependencies,
|
|
46
|
+
* this only applies to libraries.
|
|
47
|
+
* @property {boolean} glob - Glob expression or list of glob expressions to exclude
|
|
48
|
+
* dependencies from the package.json.
|
|
49
|
+
*/
|
|
50
|
+
type ExternalizeLibs = {
|
|
51
|
+
default: boolean;
|
|
52
|
+
glob: string | string[];
|
|
53
|
+
};
|
|
54
|
+
type ResolveEnvs = {
|
|
55
|
+
default: boolean;
|
|
56
|
+
local: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Project configuration.
|
|
60
|
+
*
|
|
61
|
+
* @property {ProjectType} type - Type of the project.
|
|
62
|
+
* @property {string} path - Path of the project.
|
|
63
|
+
* @property {string} entry - Path of the file entry point.
|
|
64
|
+
* @property {string} name - Name of the project, it is also used to define the name of the library.
|
|
65
|
+
* @property {string} port - Server port.
|
|
66
|
+
* @property {boolean} debug - Print data purification data.
|
|
67
|
+
* @property {boolean} dts - Control if the .d.ts files are generated, by default it is True.
|
|
68
|
+
* @property {Partial<ResolveEnvs>} resolveEnvs - Flag for resolving environment.
|
|
69
|
+
* @property {boolean} shadowDom - If component is render into shadow dom.
|
|
70
|
+
* @property {Partial<ExternalizeLibs>} externalizeLibs - Configuration for externalizing libraries.
|
|
71
|
+
* @property {LibraryOptions['fileName']} fileName - Output file name for library.
|
|
72
|
+
* @property {string} fileName - Prefix for chunk file name.
|
|
73
|
+
* @property {ViteEnv} viteEnv - Vite environment configuration.
|
|
74
|
+
* @property {UserConfig} overrides - Overrides for vite configuration.
|
|
75
|
+
*/
|
|
76
|
+
interface ProjectConfig {
|
|
77
|
+
type: ProjectType;
|
|
78
|
+
path: string;
|
|
79
|
+
entry?: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
port?: number;
|
|
82
|
+
logLevel?: LogLevel;
|
|
83
|
+
dts?: boolean;
|
|
84
|
+
resolveEnvs?: Partial<ResolveEnvs>;
|
|
85
|
+
shadowDom?: boolean;
|
|
86
|
+
externalizeLibs?: Partial<ExternalizeLibs>;
|
|
87
|
+
fileName?: LibraryOptions['fileName'];
|
|
88
|
+
chunkPrefix?: string;
|
|
89
|
+
viteEnv: ViteEnv;
|
|
90
|
+
overrides?: UserConfig;
|
|
91
|
+
}
|
|
92
|
+
interface ProjectConfigInitialized extends ProjectConfig {
|
|
93
|
+
name: string;
|
|
94
|
+
fileName: string;
|
|
95
|
+
chunkPrefix: string;
|
|
96
|
+
logLevel: LogLevel;
|
|
97
|
+
overrides: UserConfig;
|
|
98
|
+
shadowDom: boolean;
|
|
99
|
+
resolveEnvs: ResolveEnvs;
|
|
100
|
+
externalizeLibs: ExternalizeLibs;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Vite command details.
|
|
104
|
+
* @interface
|
|
105
|
+
* @property {Stage} stage - Stage of the project.
|
|
106
|
+
* @property {string} target - Command name.
|
|
107
|
+
* @property {Record<string, any>} flags - Flags for customize command.
|
|
108
|
+
*/
|
|
109
|
+
interface ViteCommand {
|
|
110
|
+
stage: Stage;
|
|
111
|
+
target: string;
|
|
112
|
+
flags: Record<string, any>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Common project configuration.
|
|
116
|
+
*
|
|
117
|
+
* @property {string} envPrefix - Prefix in lowercase for environment variables and output files.
|
|
118
|
+
* @property {boolean} externalizeLibGlob - Glob expression or list of glob expressions to exclude
|
|
119
|
+
* dependencies from the package.json.
|
|
120
|
+
*/
|
|
121
|
+
interface CommonProjectConfig {
|
|
122
|
+
envPrefix: string;
|
|
123
|
+
externalizeLibGlob?: string | string[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Config builder context.
|
|
127
|
+
*
|
|
128
|
+
* @property {CommonProjectConfig} commonConfig - Common configuration for the project.
|
|
129
|
+
* @property {ProjectConfigInitialized} projectConfig - Initialized project configuration.
|
|
130
|
+
* @property {ViteCommandDetail} viteCmd - Vite command details.
|
|
131
|
+
*/
|
|
132
|
+
interface Context {
|
|
133
|
+
commonConfig: CommonProjectConfig;
|
|
134
|
+
projectConfig: ProjectConfigInitialized;
|
|
135
|
+
viteCmd: ViteCommand;
|
|
136
|
+
localPkgJson: Record<string, any>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Interface for plugin configuration.
|
|
140
|
+
*/
|
|
141
|
+
interface PluginConfig {
|
|
142
|
+
/**
|
|
143
|
+
* Generates plugin(s) based on the provided configuration.
|
|
144
|
+
* @param {Context} ctx - The main configuration object.
|
|
145
|
+
* @returns {any[]} An array of plugins.
|
|
146
|
+
*/
|
|
147
|
+
generate: (ctx: Context) => any[];
|
|
148
|
+
/**
|
|
149
|
+
* Condition to determine if the plugin(s) should be included.
|
|
150
|
+
* @param {Context} ctx - The main configuration object.
|
|
151
|
+
* @returns {boolean} True if the plugin(s) should be included; false otherwise.
|
|
152
|
+
*/
|
|
153
|
+
condition?: (ctx: Context) => boolean;
|
|
154
|
+
}
|
|
155
|
+
export { ViteMode, Stage, ProjectType, Flag, Target, ViteEnv, ExternalizeLibs, ResolveEnvs, ProjectConfig, ProjectConfigInitialized, ViteCommand, CommonProjectConfig, Context, PluginConfig };
|
package/dist/{src/vite/config-builder/shared/types.js → esm/vite/config-builder/shared/types.mjs}
RENAMED
|
@@ -1,30 +1,3 @@
|
|
|
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
|
-
Flag: function() {
|
|
13
|
-
return Flag;
|
|
14
|
-
},
|
|
15
|
-
ProjectType: function() {
|
|
16
|
-
return ProjectType;
|
|
17
|
-
},
|
|
18
|
-
Stage: function() {
|
|
19
|
-
return Stage;
|
|
20
|
-
},
|
|
21
|
-
Target: function() {
|
|
22
|
-
return Target;
|
|
23
|
-
},
|
|
24
|
-
ViteMode: function() {
|
|
25
|
-
return ViteMode;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
1
|
var ViteMode;
|
|
29
2
|
(function(ViteMode) {
|
|
30
3
|
ViteMode["PROD"] = "production";
|
|
@@ -56,3 +29,5 @@ var Target;
|
|
|
56
29
|
Target["PREVIEW"] = "preview";
|
|
57
30
|
Target["SERVE"] = "serve";
|
|
58
31
|
})(Target || (Target = {}));
|
|
32
|
+
|
|
33
|
+
export { Flag, ProjectType, Stage, Target, ViteMode };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { PreRenderedChunk } from 'rollup';
|
|
2
|
+
import { PluginOption } from 'vite';
|
|
3
|
+
import { Context, PluginConfig } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Deeply merges two objects, combining their properties.
|
|
6
|
+
*
|
|
7
|
+
* @param {Record<string, any>} v1 - The first object.
|
|
8
|
+
* @param {Record<string, any>} v2 - The second object.
|
|
9
|
+
* @returns {Record<string, any>} - The merged object.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
13
|
+
* const obj2 = { b: { d: 3 } };
|
|
14
|
+
* const merged = deepMerge(obj1, obj2); // Outputs: { a: 1, b: { c: 2, d: 3 } }
|
|
15
|
+
*/
|
|
16
|
+
declare function deepMerge(v1: Record<string, any>, v2: Record<string, any>): Record<string, any>;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a name for js files.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} [prefix] - An optional prefix for the chunk name.
|
|
21
|
+
* @returns - A function that takes an item and generates a chunk name.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const generateChunkName = chunkName('prefix');
|
|
25
|
+
* const name = generateChunkName({ name: 'example' }); // Outputs: "prefix-example-Aj3_Dk7_2j.js"
|
|
26
|
+
*/
|
|
27
|
+
declare const chunkName: (prefix?: string) => (x: PreRenderedChunk) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the given object if the condition is true, otherwise returns null.
|
|
30
|
+
*
|
|
31
|
+
* @param {any} condition - The condition to evaluate.
|
|
32
|
+
* @param {Record<string, any>} obj - The object to return if the condition is true.
|
|
33
|
+
* @returns {Record<string, any> | null} - The object or null based on the condition.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const obj = { a: 1 };
|
|
37
|
+
* const result = when(true, obj); // Outputs: { a: 1 }
|
|
38
|
+
* const result2 = when(false, obj); // Outputs: {}
|
|
39
|
+
*/
|
|
40
|
+
declare const when: (condition: any, obj: Record<string, any>) => Record<string, any>;
|
|
41
|
+
/**
|
|
42
|
+
* Filters and generates plugin configurations based on conditions and the provided context.
|
|
43
|
+
*
|
|
44
|
+
* @param {Context} ctx - The main configuration object.
|
|
45
|
+
* @returns {any[]} - An array of generated plugin configurations.
|
|
46
|
+
*/
|
|
47
|
+
declare const getPlugins: (ctx: Context, ...pluginConfigs: PluginConfig[]) => PluginOption[];
|
|
48
|
+
/**
|
|
49
|
+
* Gets the paths to the tsconfig files for all relevant projects.
|
|
50
|
+
*
|
|
51
|
+
* @returns {string[]} - An array containing paths to tsconfig files for both app and lib projects.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const projects = {
|
|
55
|
+
* 'my-app': {
|
|
56
|
+
* type: 'app',
|
|
57
|
+
* data: { root: 'apps/my-app' }
|
|
58
|
+
* },
|
|
59
|
+
* 'my-lib': {
|
|
60
|
+
* type: 'lib',
|
|
61
|
+
* data: { root: 'libs/my-lib' }
|
|
62
|
+
* }
|
|
63
|
+
* };
|
|
64
|
+
*
|
|
65
|
+
* const tsConfigPaths = getTsConfigPaths(projects);
|
|
66
|
+
* console.log(tsConfigPaths);
|
|
67
|
+
* // Output:
|
|
68
|
+
* // ['apps/my-app/tsconfig.app.json', 'libs/my-lib/tsconfig.lib.json']
|
|
69
|
+
*/
|
|
70
|
+
declare const getNxTsConfigPaths: () => string[];
|
|
71
|
+
export { deepMerge, chunkName, when, getPlugins, getNxTsConfigPaths };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { readCachedProjectGraph } from '@nx/devkit';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
import '../../../../shared/logger.mjs';
|
|
5
|
+
import { shortId } from '../../../../shared/utils.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Deeply merges two objects, combining their properties.
|
|
9
|
+
*
|
|
10
|
+
* @param {Record<string, any>} v1 - The first object.
|
|
11
|
+
* @param {Record<string, any>} v2 - The second object.
|
|
12
|
+
* @returns {Record<string, any>} - The merged object.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
16
|
+
* const obj2 = { b: { d: 3 } };
|
|
17
|
+
* const merged = deepMerge(obj1, obj2); // Outputs: { a: 1, b: { c: 2, d: 3 } }
|
|
18
|
+
*/ function deepMerge(v1, v2) {
|
|
19
|
+
if (Array.isArray(v1) && Array.isArray(v2)) {
|
|
20
|
+
return R.uniq(R.concat(v1, v2));
|
|
21
|
+
} else if (typeof v1 === 'object' && typeof v2 === 'object' && !R.isNil(v1) && !R.isNil(v2)) {
|
|
22
|
+
return R.mergeWith(deepMerge, v1, v2);
|
|
23
|
+
} else {
|
|
24
|
+
return v2;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generates a name for js files.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} [prefix] - An optional prefix for the chunk name.
|
|
31
|
+
* @returns - A function that takes an item and generates a chunk name.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const generateChunkName = chunkName('prefix');
|
|
35
|
+
* const name = generateChunkName({ name: 'example' }); // Outputs: "prefix-example-Aj3_Dk7_2j.js"
|
|
36
|
+
*/ const chunkName = (prefix)=>(x)=>{
|
|
37
|
+
const nameWithoutUnderscore = x.name.replace(/_/g, '');
|
|
38
|
+
const pre = prefix ? `${prefix}-` : '';
|
|
39
|
+
return `${pre}${nameWithoutUnderscore}-${shortId(8)}.js`;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Returns the given object if the condition is true, otherwise returns null.
|
|
43
|
+
*
|
|
44
|
+
* @param {any} condition - The condition to evaluate.
|
|
45
|
+
* @param {Record<string, any>} obj - The object to return if the condition is true.
|
|
46
|
+
* @returns {Record<string, any> | null} - The object or null based on the condition.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const obj = { a: 1 };
|
|
50
|
+
* const result = when(true, obj); // Outputs: { a: 1 }
|
|
51
|
+
* const result2 = when(false, obj); // Outputs: {}
|
|
52
|
+
*/ const when = (condition, obj)=>condition ? obj : {};
|
|
53
|
+
/**
|
|
54
|
+
* Filters and generates plugin configurations based on conditions and the provided context.
|
|
55
|
+
*
|
|
56
|
+
* @param {Context} ctx - The main configuration object.
|
|
57
|
+
* @returns {any[]} - An array of generated plugin configurations.
|
|
58
|
+
*/ const getPlugins = (ctx, ...pluginConfigs)=>pluginConfigs // Filters the plugins based on conditions
|
|
59
|
+
.filter((p)=>!p.condition || p.condition(ctx)) // Generates the configuration of each plugin and flattens the resulting array
|
|
60
|
+
.flatMap((p)=>p.generate(ctx));
|
|
61
|
+
/**
|
|
62
|
+
* Gets the paths to the tsconfig files for all relevant projects.
|
|
63
|
+
*
|
|
64
|
+
* @returns {string[]} - An array containing paths to tsconfig files for both app and lib projects.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const projects = {
|
|
68
|
+
* 'my-app': {
|
|
69
|
+
* type: 'app',
|
|
70
|
+
* data: { root: 'apps/my-app' }
|
|
71
|
+
* },
|
|
72
|
+
* 'my-lib': {
|
|
73
|
+
* type: 'lib',
|
|
74
|
+
* data: { root: 'libs/my-lib' }
|
|
75
|
+
* }
|
|
76
|
+
* };
|
|
77
|
+
*
|
|
78
|
+
* const tsConfigPaths = getTsConfigPaths(projects);
|
|
79
|
+
* console.log(tsConfigPaths);
|
|
80
|
+
* // Output:
|
|
81
|
+
* // ['apps/my-app/tsconfig.app.json', 'libs/my-lib/tsconfig.lib.json']
|
|
82
|
+
*/ const getNxTsConfigPaths = ()=>{
|
|
83
|
+
const isValid = (p)=>p.data.root.startsWith('apps/') || p.data.root.startsWith('libs/');
|
|
84
|
+
const getTsConfigPath = (p)=>resolve(p.data.root, `tsconfig.${p.type === 'app' ? 'app' : 'lib'}.json`);
|
|
85
|
+
const graph = readCachedProjectGraph();
|
|
86
|
+
const projects = graph.nodes;
|
|
87
|
+
return Object.values(projects).filter(isValid).map(getTsConfigPath);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export { chunkName, deepMerge, getNxTsConfigPaths, getPlugins, when };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { UserConfig } from 'vite';
|
|
2
|
+
import { CommonProjectConfig, ProjectConfig, ProjectConfigInitialized } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the project configuration with default values.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const config = { type: ProjectType.APP, path: '/path/to/project', viteEnv: { mode: ViteMode.DEV } };
|
|
8
|
+
* const initializedConfig = initializeConfig(config);
|
|
9
|
+
*/
|
|
10
|
+
declare const initializeConfig: (ccfg: CommonProjectConfig, pcfg: ProjectConfig, localPkgJson: Record<string, any>) => {
|
|
11
|
+
viteCmd: import("../types.js").ViteCommand;
|
|
12
|
+
cfg: ProjectConfigInitialized;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Handles merging configurations and logs any errors.
|
|
16
|
+
*
|
|
17
|
+
* @param {UserConfig} defaultConfig - The default configuration.
|
|
18
|
+
* @param {UserConfig} overrides - The overrides configuration.
|
|
19
|
+
* @returns {UserConfig} - The merged configuration.
|
|
20
|
+
*/
|
|
21
|
+
declare const mergeConfigs: (defaultConfig: UserConfig, overrides: UserConfig) => UserConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves glob patterns to actual package names found in package.json dependencies.
|
|
24
|
+
* This function is used to determine which packages should be treated as external
|
|
25
|
+
* in a Rollup or Vite build configuration.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} path - The base path where package.json is located.
|
|
28
|
+
* @param {string | string[]} globs - A glob pattern or an array of glob patterns to match dependencies against.
|
|
29
|
+
* @returns {string[]} An array of package names that match the given glob patterns.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Example of using `getExternalDependencies` to find all dependencies starting with "my-lib" and "lodash"
|
|
33
|
+
* const projectPath = '/path/to/project';
|
|
34
|
+
* const globs = ['my-lib*', 'lodash'];
|
|
35
|
+
* const externalDependencies = getExternalDependencies(projectPath, globs);
|
|
36
|
+
* console.log(externalDependencies);
|
|
37
|
+
* // Output might be: ['my-lib/utils', 'my-lib/core', 'lodash']
|
|
38
|
+
*/
|
|
39
|
+
declare const getExternalDependencies: (path: string, globs?: string | string[]) => string[];
|
|
40
|
+
/**
|
|
41
|
+
* Generates a string of initials based on the input string,
|
|
42
|
+
* following certain rules:
|
|
43
|
+
* 1. A word is considered as a sequence of characters
|
|
44
|
+
* separated by hyphens.
|
|
45
|
+
* 2. If the string contains '@', any characters before
|
|
46
|
+
* and including the next '/' are ignored.
|
|
47
|
+
* 3. The first character of each word is taken to form
|
|
48
|
+
* the initials.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} input - The input string from which to generate the initials.
|
|
51
|
+
* @returns {string} The initials formed by taking the first character
|
|
52
|
+
* of each word, after applying the specified rules.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* getInitials("player-script"); // returns "ps"
|
|
56
|
+
* getInitials("ssv-admin"); // returns "sa"
|
|
57
|
+
* getInitials("@nizza/customize-live"); // returns "cl"
|
|
58
|
+
*/
|
|
59
|
+
declare function getInitials(input: string): string;
|
|
60
|
+
export { initializeConfig, mergeConfigs, getExternalDependencies, getInitials };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { minimatch } from 'minimatch';
|
|
2
|
+
import { LogLevel, setLogLevel, logger } from '../../../../shared/logger.mjs';
|
|
3
|
+
import { getPkgJson } from '../../../../shared/utils.mjs';
|
|
4
|
+
import { Flag } from '../types.mjs';
|
|
5
|
+
import { deepMerge } from './helpers.mjs';
|
|
6
|
+
import { getViteCommand } from './viteCommand.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the project configuration with default values.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const config = { type: ProjectType.APP, path: '/path/to/project', viteEnv: { mode: ViteMode.DEV } };
|
|
13
|
+
* const initializedConfig = initializeConfig(config);
|
|
14
|
+
*/ const initializeConfig = (ccfg, pcfg, localPkgJson)=>{
|
|
15
|
+
const { envPrefix } = ccfg;
|
|
16
|
+
const localPkgName = localPkgJson['name'];
|
|
17
|
+
const { name = localPkgName, overrides = {}, shadowDom = false, chunkPrefix = getInitials(localPkgName), resolveEnvs = {
|
|
18
|
+
default: true,
|
|
19
|
+
local: true
|
|
20
|
+
}, fileName = `${envPrefix}-${chunkPrefix}-index`, externalizeLibs = {
|
|
21
|
+
default: true,
|
|
22
|
+
glob: []
|
|
23
|
+
} } = pcfg;
|
|
24
|
+
const viteCmd = getViteCommand(pcfg.viteEnv.mode);
|
|
25
|
+
const isVerbose = Object.keys(viteCmd.flags).some((x)=>[
|
|
26
|
+
Flag.VERBOSE,
|
|
27
|
+
Flag.VERBOSE_ALIAS
|
|
28
|
+
].includes(x));
|
|
29
|
+
const logLevel = isVerbose ? LogLevel.DEBUG : pcfg.logLevel ?? LogLevel.INFO;
|
|
30
|
+
setLogLevel(logLevel);
|
|
31
|
+
return {
|
|
32
|
+
viteCmd,
|
|
33
|
+
cfg: {
|
|
34
|
+
...pcfg,
|
|
35
|
+
name,
|
|
36
|
+
fileName,
|
|
37
|
+
logLevel,
|
|
38
|
+
overrides,
|
|
39
|
+
chunkPrefix,
|
|
40
|
+
shadowDom,
|
|
41
|
+
resolveEnvs,
|
|
42
|
+
externalizeLibs: externalizeLibs
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Handles merging configurations and logs any errors.
|
|
48
|
+
*
|
|
49
|
+
* @param {UserConfig} defaultConfig - The default configuration.
|
|
50
|
+
* @param {UserConfig} overrides - The overrides configuration.
|
|
51
|
+
* @returns {UserConfig} - The merged configuration.
|
|
52
|
+
*/ const mergeConfigs = (defaultConfig, overrides)=>{
|
|
53
|
+
try {
|
|
54
|
+
return deepMerge(defaultConfig, overrides);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
logger.error('Error merging vite configs: ', err);
|
|
57
|
+
return defaultConfig;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Resolves glob patterns to actual package names found in package.json dependencies.
|
|
62
|
+
* This function is used to determine which packages should be treated as external
|
|
63
|
+
* in a Rollup or Vite build configuration.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} path - The base path where package.json is located.
|
|
66
|
+
* @param {string | string[]} globs - A glob pattern or an array of glob patterns to match dependencies against.
|
|
67
|
+
* @returns {string[]} An array of package names that match the given glob patterns.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Example of using `getExternalDependencies` to find all dependencies starting with "my-lib" and "lodash"
|
|
71
|
+
* const projectPath = '/path/to/project';
|
|
72
|
+
* const globs = ['my-lib*', 'lodash'];
|
|
73
|
+
* const externalDependencies = getExternalDependencies(projectPath, globs);
|
|
74
|
+
* console.log(externalDependencies);
|
|
75
|
+
* // Output might be: ['my-lib/utils', 'my-lib/core', 'lodash']
|
|
76
|
+
*/ const getExternalDependencies = (path, globs = [])=>{
|
|
77
|
+
const pkgJson = getPkgJson(path); // Assumes getLocalPkgJson is a function that reads and parses package.json
|
|
78
|
+
const dependencies = Object.keys(pkgJson.dependencies || {});
|
|
79
|
+
const globPatterns = Array.isArray(globs) ? globs : [
|
|
80
|
+
globs
|
|
81
|
+
];
|
|
82
|
+
return dependencies.filter((dep)=>globPatterns.some((pattern)=>minimatch(dep, pattern)));
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Generates a string of initials based on the input string,
|
|
86
|
+
* following certain rules:
|
|
87
|
+
* 1. A word is considered as a sequence of characters
|
|
88
|
+
* separated by hyphens.
|
|
89
|
+
* 2. If the string contains '@', any characters before
|
|
90
|
+
* and including the next '/' are ignored.
|
|
91
|
+
* 3. The first character of each word is taken to form
|
|
92
|
+
* the initials.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} input - The input string from which to generate the initials.
|
|
95
|
+
* @returns {string} The initials formed by taking the first character
|
|
96
|
+
* of each word, after applying the specified rules.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* getInitials("player-script"); // returns "ps"
|
|
100
|
+
* getInitials("ssv-admin"); // returns "sa"
|
|
101
|
+
* getInitials("@nizza/customize-live"); // returns "cl"
|
|
102
|
+
*/ function getInitials(input) {
|
|
103
|
+
const cleanedInput = input.includes('@') ? input.split('/')[1] : input;
|
|
104
|
+
const words = cleanedInput?.split('-');
|
|
105
|
+
const initials = words?.map((word)=>word.charAt(0)).join('');
|
|
106
|
+
return initials ?? '';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { getExternalDependencies, getInitials, initializeConfig, mergeConfigs };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ViteMode, ViteCommand } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the Vite command details.
|
|
4
|
+
*
|
|
5
|
+
* @param {ViteMode} mode - The Vite mode.
|
|
6
|
+
* @returns {ViteCommand} - The command details.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const command = getViteCommand(ViteMode.PROD);
|
|
10
|
+
* // Outputs: { stage: Stage.PROD, target: 'build', flags: {} }
|
|
11
|
+
*/
|
|
12
|
+
declare function getViteCommand(mode: ViteMode): ViteCommand;
|
|
13
|
+
/**
|
|
14
|
+
* Parses the command string to extract flags.
|
|
15
|
+
*
|
|
16
|
+
* @param {string | undefined} commandString - The command string.
|
|
17
|
+
* @returns {Record<string, string>} - The flags extracted from the command string.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const flags = getViteCmdFlags('nx run core:build --source-maps');
|
|
21
|
+
* // Outputs: { 'source-maps: 'true' }
|
|
22
|
+
*/
|
|
23
|
+
declare function getViteCmdFlags(commandString: string | undefined): Record<string, string>;
|
|
24
|
+
export { getViteCommand, getViteCmdFlags };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import argv from 'mri';
|
|
3
|
+
import { loadEnv } from 'vite';
|
|
4
|
+
import { ViteMode, Stage, Target } from '../types.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves the Vite command details.
|
|
8
|
+
*
|
|
9
|
+
* @param {ViteMode} mode - The Vite mode.
|
|
10
|
+
* @returns {ViteCommand} - The command details.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const command = getViteCommand(ViteMode.PROD);
|
|
14
|
+
* // Outputs: { stage: Stage.PROD, target: 'build', flags: {} }
|
|
15
|
+
*/ function getViteCommand(mode) {
|
|
16
|
+
const nxEnv = loadEnv(mode, process.cwd(), 'NX');
|
|
17
|
+
const nxCommandString = process?.env?.['npm_package_scripts_nx'];
|
|
18
|
+
const modeIsProd = mode === ViteMode.PROD;
|
|
19
|
+
const stage = (nxEnv?.['NX_TASK_TARGET_CONFIGURATION']) ?? (modeIsProd ? Stage.PROD : Stage.DEV);
|
|
20
|
+
const target = nxEnv?.['NX_TASK_TARGET_TARGET'] ?? Target.BUILD;
|
|
21
|
+
const flags = getViteCmdFlags(nxCommandString);
|
|
22
|
+
const showIn = {
|
|
23
|
+
prod: (...args)=>modeIsProd && console.log(...args),
|
|
24
|
+
dev: (...args)=>!modeIsProd && console.log(...args)
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
showIn.prod(chalk.cyan('Build Stage:'), chalk.green(stage));
|
|
28
|
+
showIn.dev(chalk.green(' ➜ '), chalk.bold.white(`Stage: `), chalk.cyan(stage));
|
|
29
|
+
} catch {
|
|
30
|
+
showIn.prod(console.log('Build Stage:', stage));
|
|
31
|
+
showIn.dev(console.log(` ➜ Stage: `, stage));
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
stage,
|
|
35
|
+
target,
|
|
36
|
+
flags
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parses the command string to extract flags.
|
|
41
|
+
*
|
|
42
|
+
* @param {string | undefined} commandString - The command string.
|
|
43
|
+
* @returns {Record<string, string>} - The flags extracted from the command string.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const flags = getViteCmdFlags('nx run core:build --source-maps');
|
|
47
|
+
* // Outputs: { 'source-maps: 'true' }
|
|
48
|
+
*/ function getViteCmdFlags(commandString) {
|
|
49
|
+
if (!commandString) return {};
|
|
50
|
+
const cleanedCommandString = commandString.replace(/"/g, '');
|
|
51
|
+
const args = argv(cleanedCommandString.split(' '));
|
|
52
|
+
delete args['_'];
|
|
53
|
+
return args;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { getViteCmdFlags, getViteCommand };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function injectCssIntoShadowDom() {
|
|
2
|
+
const fileRegex = /\.(css)$/;
|
|
3
|
+
let server;
|
|
4
|
+
return {
|
|
5
|
+
name: 'nizza:inject-css-into-shadow-dom',
|
|
6
|
+
configureServer (_server) {
|
|
7
|
+
server = _server;
|
|
8
|
+
},
|
|
9
|
+
transform (src, id) {
|
|
10
|
+
if (server) {
|
|
11
|
+
const relativeId = /\/lib\/.*/.exec(id)?.[0].replace('/lib/', '');
|
|
12
|
+
if (fileRegex.test(id)) {
|
|
13
|
+
server.ws.send({
|
|
14
|
+
type: 'custom',
|
|
15
|
+
event: 'inject-css-into-shadow-dom:hot-updated',
|
|
16
|
+
data: {
|
|
17
|
+
id: relativeId,
|
|
18
|
+
content: src
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { injectCssIntoShadowDom };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
interface Execute {
|
|
3
|
+
function: (data?: string) => void;
|
|
4
|
+
listen: string;
|
|
5
|
+
observer: string;
|
|
6
|
+
}
|
|
7
|
+
interface ThirdPartyCssInjectPlugin {
|
|
8
|
+
topExecutionPriority?: boolean;
|
|
9
|
+
execute?: Execute[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Inject the CSS compiled with JS.
|
|
13
|
+
*
|
|
14
|
+
* @return {Plugin}
|
|
15
|
+
*/
|
|
16
|
+
declare function thirdPartyCssInjectPlugin({ topExecutionPriority, execute }?: ThirdPartyCssInjectPlugin | undefined): Plugin;
|
|
17
|
+
export { Execute, ThirdPartyCssInjectPlugin, thirdPartyCssInjectPlugin };
|