@nizza/devkit 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +7 -0
  2. package/dist/package.json +13 -0
  3. package/dist/src/executors/deploy/executor.d.ts +11 -0
  4. package/dist/src/executors/deploy/executor.d.ts.map +1 -0
  5. package/dist/src/executors/deploy/executor.js +27 -0
  6. package/dist/src/executors/deploy/helpers.d.ts +4 -0
  7. package/dist/src/executors/deploy/helpers.d.ts.map +1 -0
  8. package/dist/src/executors/deploy/helpers.js +40 -0
  9. package/dist/src/executors/deploy/schema.json +41 -0
  10. package/dist/src/executors/environments/executor.d.ts +16 -0
  11. package/dist/src/executors/environments/executor.d.ts.map +1 -0
  12. package/dist/src/executors/environments/executor.js +59 -0
  13. package/dist/src/executors/environments/helpers.d.ts +21 -0
  14. package/dist/src/executors/environments/helpers.d.ts.map +1 -0
  15. package/dist/src/executors/environments/helpers.js +63 -0
  16. package/dist/src/executors/environments/schema.json +9 -0
  17. package/dist/src/executors/publish/executor.d.ts +12 -0
  18. package/dist/src/executors/publish/executor.d.ts.map +1 -0
  19. package/dist/src/executors/publish/executor.js +57 -0
  20. package/dist/src/executors/publish/helpers.d.ts +19 -0
  21. package/dist/src/executors/publish/helpers.d.ts.map +1 -0
  22. package/dist/src/executors/publish/helpers.js +52 -0
  23. package/dist/src/executors/publish/schema.json +19 -0
  24. package/dist/src/executors/shared/index.d.ts +3 -0
  25. package/dist/src/executors/shared/index.d.ts.map +1 -0
  26. package/dist/src/executors/shared/index.js +7 -0
  27. package/dist/src/executors/shared/types.d.ts +4 -0
  28. package/dist/src/executors/shared/types.d.ts.map +1 -0
  29. package/dist/src/executors/shared/types.js +4 -0
  30. package/dist/src/executors/shared/utils.d.ts +34 -0
  31. package/dist/src/executors/shared/utils.d.ts.map +1 -0
  32. package/dist/src/executors/shared/utils.js +74 -0
  33. package/dist/src/executors/update-executors-file/executor.d.ts +12 -0
  34. package/dist/src/executors/update-executors-file/executor.d.ts.map +1 -0
  35. package/dist/src/executors/update-executors-file/executor.js +46 -0
  36. package/dist/src/executors/update-executors-file/helpers.d.ts +24 -0
  37. package/dist/src/executors/update-executors-file/helpers.d.ts.map +1 -0
  38. package/dist/src/executors/update-executors-file/helpers.js +70 -0
  39. package/dist/src/executors/update-executors-file/schema.json +9 -0
  40. package/dist/src/executors/update-executors-file/types.d.ts +14 -0
  41. package/dist/src/executors/update-executors-file/types.d.ts.map +1 -0
  42. package/dist/src/executors/update-executors-file/types.js +4 -0
  43. package/dist/src/executors/vtex-link/constants.d.ts +4 -0
  44. package/dist/src/executors/vtex-link/constants.d.ts.map +1 -0
  45. package/dist/src/executors/vtex-link/constants.js +24 -0
  46. package/dist/src/executors/vtex-link/executor.d.ts +5 -0
  47. package/dist/src/executors/vtex-link/executor.d.ts.map +1 -0
  48. package/dist/src/executors/vtex-link/executor.js +35 -0
  49. package/dist/src/executors/vtex-link/helpers.d.ts +77 -0
  50. package/dist/src/executors/vtex-link/helpers.d.ts.map +1 -0
  51. package/dist/src/executors/vtex-link/helpers.js +187 -0
  52. package/dist/src/executors/vtex-link/schema.json +25 -0
  53. package/dist/src/executors/vtex-link/types.d.ts +12 -0
  54. package/dist/src/executors/vtex-link/types.d.ts.map +1 -0
  55. package/dist/src/executors/vtex-link/types.js +4 -0
  56. package/dist/src/index.d.ts +2 -0
  57. package/dist/src/index.d.ts.map +1 -0
  58. package/dist/src/index.js +6 -0
  59. package/dist/src/logger.d.ts +34 -0
  60. package/dist/src/logger.d.ts.map +1 -0
  61. package/dist/src/logger.js +106 -0
  62. package/dist/src/scripts/changeset-pre-mode.d.ts +2 -0
  63. package/dist/src/scripts/changeset-pre-mode.d.ts.map +1 -0
  64. package/dist/src/scripts/changeset-pre-mode.js +41 -0
  65. package/dist/src/shared/index.d.ts +2 -0
  66. package/dist/src/shared/index.d.ts.map +1 -0
  67. package/dist/src/shared/index.js +6 -0
  68. package/dist/src/shared/utils.d.ts +11 -0
  69. package/dist/src/shared/utils.d.ts.map +1 -0
  70. package/dist/src/shared/utils.js +22 -0
  71. package/dist/src/vite/config-builder/configs/app.d.ts +4 -0
  72. package/dist/src/vite/config-builder/configs/app.d.ts.map +1 -0
  73. package/dist/src/vite/config-builder/configs/app.js +19 -0
  74. package/dist/src/vite/config-builder/configs/base.d.ts +4 -0
  75. package/dist/src/vite/config-builder/configs/base.d.ts.map +1 -0
  76. package/dist/src/vite/config-builder/configs/base.js +55 -0
  77. package/dist/src/vite/config-builder/configs/index.d.ts +7 -0
  78. package/dist/src/vite/config-builder/configs/index.d.ts.map +1 -0
  79. package/dist/src/vite/config-builder/configs/index.js +28 -0
  80. package/dist/src/vite/config-builder/configs/lib.d.ts +4 -0
  81. package/dist/src/vite/config-builder/configs/lib.d.ts.map +1 -0
  82. package/dist/src/vite/config-builder/configs/lib.js +57 -0
  83. package/dist/src/vite/config-builder/configs/script.d.ts +4 -0
  84. package/dist/src/vite/config-builder/configs/script.d.ts.map +1 -0
  85. package/dist/src/vite/config-builder/configs/script.js +42 -0
  86. package/dist/src/vite/config-builder/index.d.ts +3 -0
  87. package/dist/src/vite/config-builder/index.d.ts.map +1 -0
  88. package/dist/src/vite/config-builder/index.js +7 -0
  89. package/dist/src/vite/config-builder/main.d.ts +10 -0
  90. package/dist/src/vite/config-builder/main.d.ts.map +1 -0
  91. package/dist/src/vite/config-builder/main.js +37 -0
  92. package/dist/src/vite/config-builder/plugins.d.ts +30 -0
  93. package/dist/src/vite/config-builder/plugins.d.ts.map +1 -0
  94. package/dist/src/vite/config-builder/plugins.js +88 -0
  95. package/dist/src/vite/config-builder/shared/index.d.ts +3 -0
  96. package/dist/src/vite/config-builder/shared/index.d.ts.map +1 -0
  97. package/dist/src/vite/config-builder/shared/index.js +7 -0
  98. package/dist/src/vite/config-builder/shared/types.d.ts +155 -0
  99. package/dist/src/vite/config-builder/shared/types.d.ts.map +1 -0
  100. package/dist/src/vite/config-builder/shared/types.js +58 -0
  101. package/dist/src/vite/config-builder/shared/utils/helpers.d.ts +81 -0
  102. package/dist/src/vite/config-builder/shared/utils/helpers.d.ts.map +1 -0
  103. package/dist/src/vite/config-builder/shared/utils/helpers.js +61 -0
  104. package/dist/src/vite/config-builder/shared/utils/index.d.ts +4 -0
  105. package/dist/src/vite/config-builder/shared/utils/index.d.ts.map +1 -0
  106. package/dist/src/vite/config-builder/shared/utils/index.js +8 -0
  107. package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts +60 -0
  108. package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts.map +1 -0
  109. package/dist/src/vite/config-builder/shared/utils/projectConfig.js +85 -0
  110. package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts +24 -0
  111. package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts.map +1 -0
  112. package/dist/src/vite/config-builder/shared/utils/viteCommand.js +54 -0
  113. package/dist/src/vite/index.d.ts +3 -0
  114. package/dist/src/vite/index.d.ts.map +1 -0
  115. package/dist/src/vite/index.js +7 -0
  116. package/dist/src/vite/plugins/index.d.ts +3 -0
  117. package/dist/src/vite/plugins/index.d.ts.map +1 -0
  118. package/dist/src/vite/plugins/index.js +7 -0
  119. package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts +8 -0
  120. package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts.map +1 -0
  121. package/dist/src/vite/plugins/shadow-dom-inject-css/index.js +44 -0
  122. package/dist/src/vite/plugins/third-party-css-inject/index.d.ts +4 -0
  123. package/dist/src/vite/plugins/third-party-css-inject/index.d.ts.map +1 -0
  124. package/dist/src/vite/plugins/third-party-css-inject/index.js +13 -0
  125. package/dist/src/vite/plugins/third-party-css-inject/main.d.ts +17 -0
  126. package/dist/src/vite/plugins/third-party-css-inject/main.d.ts.map +1 -0
  127. package/dist/src/vite/plugins/third-party-css-inject/main.js +48 -0
  128. package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts +5 -0
  129. package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts.map +1 -0
  130. package/dist/src/vite/plugins/third-party-css-inject/utils.js +112 -0
  131. package/package.json +12 -0
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,2 @@
1
+ export * from './vite';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./vite"), exports);
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Enum representing the different log levels.
3
+ */
4
+ export declare enum LogLevel {
5
+ ERROR = 0,
6
+ WARN = 1,
7
+ INFO = 2,
8
+ DEBUG = 3
9
+ }
10
+ export 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
+ export declare const setLogLevel: (level: LogLevel) => void;
27
+ export 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 default logger;
34
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAGD,eAAO,IAAI,eAAe,UAAgB,CAAC;AAgC3C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,UAAW,QAAQ,SAE1C,CAAC;AA+DF,eAAO,MAAM,MAAM;qBAtBP,MAAM,WAAW,GAAG,EAAE,KAAG,IAAI;oBAA7B,MAAM,WAAW,GAAG,EAAE,KAAG,IAAI;oBAA7B,MAAM,WAAW,GAAG,EAAE,KAAG,IAAI;qBAA7B,MAAM,WAAW,GAAG,EAAE,KAAG,IAAI;CA2BxC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,106 @@
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
+ 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");
31
+ var LogLevel;
32
+ (function(LogLevel) {
33
+ LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
34
+ LogLevel[LogLevel["WARN"] = 1] = "WARN";
35
+ LogLevel[LogLevel["INFO"] = 2] = "INFO";
36
+ LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
37
+ })(LogLevel || (LogLevel = {}));
38
+ let currentLogLevel = 2;
39
+ /**
40
+ * Object mapping log levels to console log functions.
41
+ *
42
+ * @constant {Object} logFunctions
43
+ */ const logFunctions = {
44
+ [0]: console.error,
45
+ [1]: console.warn,
46
+ [2]: console.info,
47
+ [3]: console.debug
48
+ };
49
+ /**
50
+ * Object mapping log levels to chalk color functions.
51
+ *
52
+ * @constant {Object} colorFunctions
53
+ */ const colorFunctions = {
54
+ [0]: _chalk.default.red,
55
+ [1]: _chalk.default.yellow,
56
+ [2]: _chalk.default.blue,
57
+ [3]: _chalk.default.magenta
58
+ };
59
+ const getLogLevelKey = (value)=>{
60
+ return Object.keys(LogLevel).find((key)=>LogLevel[key] === value);
61
+ };
62
+ const setLogLevel = (level)=>{
63
+ currentLogLevel = level;
64
+ };
65
+ /**
66
+ * Takes a list of arguments, stringifies each argument, and joins
67
+ * them with a newline character.
68
+ *
69
+ * @param {any[]} args - The arguments to process.
70
+ * @returns {string} - The processed string.
71
+ */ const processArgs = (0, _ramda.pipe)((0, _ramda.map)((arg)=>JSON.stringify(arg, null, 2)), (0, _ramda.join)('\n'));
72
+ /**
73
+ * Formats the log message with a timestamp, log level, and any additional variables.
74
+ *
75
+ * @param {LogLevel} level - The log level.
76
+ * @param {string} message - The message to log.
77
+ * @param {any[]} rest - Any additional variables to log.
78
+ * @returns {string} - The formatted log message.
79
+ */ const formatMessage = (level, message, ...rest)=>{
80
+ const levelKey = getLogLevelKey(level);
81
+ const timestamp = `${new Date().toLocaleTimeString()}`;
82
+ const formattedRest = rest.length ? `\n${processArgs(rest)}` : '';
83
+ return `${timestamp} [${levelKey}] ${message}${formattedRest}`;
84
+ };
85
+ /**
86
+ * Generates a log function for a specific log level.
87
+ *
88
+ * @param {LogLevel} level - The log level.
89
+ * @returns - The log function.
90
+ */ const log = (level)=>(message, ...rest)=>{
91
+ if (level > currentLogLevel) return; // Skip logging if level is below the current log level
92
+ const pipeline = (0, _ramda.pipe)(()=>formatMessage(level, message, ...rest), colorFunctions[level], logFunctions[level]);
93
+ const errPipeline = (0, _ramda.pipe)((err)=>`Failed to log message: ${err.message}`, colorFunctions[0], logFunctions[0]);
94
+ try {
95
+ pipeline();
96
+ } catch (err) {
97
+ errPipeline(err);
98
+ }
99
+ };
100
+ const logger = {
101
+ error: log(0),
102
+ warn: log(1),
103
+ info: log(2),
104
+ debug: log(3)
105
+ };
106
+ const _default = logger;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=changeset-pre-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeset-pre-mode.d.ts","sourceRoot":"","sources":["../../../src/scripts/changeset-pre-mode.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * This script uses @changeset/cli to enter prerelease mode
3
+ * but makes sure that it is not previously executed
4
+ * so that the process does not die.
5
+ */ "use strict";
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ const _devkit = require("@nx/devkit");
10
+ const _child_process = require("child_process");
11
+ const _promises = require("fs/promises");
12
+ const _path = require("path");
13
+ const _util = require("util");
14
+ const execAsync = (0, _util.promisify)(_child_process.exec);
15
+ const changesetDir = (0, _path.resolve)('.changeset');
16
+ const preJsonPath = (0, _path.resolve)(changesetDir, 'pre.json');
17
+ let preJson;
18
+ try {
19
+ const data = await (0, _promises.readFile)(preJsonPath, 'utf8');
20
+ preJson = JSON.parse(data);
21
+ } catch {
22
+ preJson = {
23
+ mode: 'exit'
24
+ };
25
+ }
26
+ // Execute "version" command using @changeset/cli
27
+ try {
28
+ const { mode } = preJson;
29
+ if (mode === 'exit') {
30
+ const command = `pnpm changeset pre enter beta`;
31
+ const { stdout, stderr } = await execAsync(command);
32
+ _devkit.logger.info(stdout);
33
+ _devkit.logger.info(stderr);
34
+ _devkit.logger.info(`🚀 Successfully enter prerelease mode`);
35
+ } else {
36
+ _devkit.logger.info(`🚀 Prerelease mode has been previously entered`);
37
+ }
38
+ } catch (error) {
39
+ _devkit.logger.error('❌ An error occurred!');
40
+ throw error;
41
+ }
@@ -0,0 +1,2 @@
1
+ export * from './utils';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./utils"), exports);
@@ -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
+ export declare const getPkgJson: (projectPath: string) => Record<string, any>;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/shared/utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,gBAAiB,MAAM,KAAG,OAAO,MAAM,EAAE,GAAG,CAQlE,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getPkgJson", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getPkgJson;
9
+ }
10
+ });
11
+ const _devkit = require("@nx/devkit");
12
+ const _fs = require("fs");
13
+ const _path = require("path");
14
+ const getPkgJson = (projectPath)=>{
15
+ try {
16
+ const data = (0, _fs.readFileSync)((0, _path.resolve)(projectPath, './package.json'), 'utf-8');
17
+ return JSON.parse(data);
18
+ } catch (err) {
19
+ _devkit.logger.error('Error reading or parsing package.json');
20
+ throw err;
21
+ }
22
+ };
@@ -0,0 +1,4 @@
1
+ import type { UserConfig } from 'vite';
2
+ import type { Context } from '../shared';
3
+ export declare const getAppConfig: (ctx: Context) => UserConfig;
4
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/configs/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,eAAO,MAAM,YAAY,QAAS,OAAO,KAAG,UAS3C,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getAppConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getAppConfig;
9
+ }
10
+ });
11
+ const getAppConfig = (ctx)=>{
12
+ const { port } = ctx.projectConfig;
13
+ return {
14
+ server: {
15
+ port,
16
+ host: true
17
+ }
18
+ };
19
+ };
@@ -0,0 +1,4 @@
1
+ import type { UserConfig } from 'vite';
2
+ import { type Context } from '../shared';
3
+ export declare const getBaseConfig: (ctx: Context) => UserConfig;
4
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/configs/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAOL,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAInB,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,UAyC5C,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getBaseConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getBaseConfig;
9
+ }
10
+ });
11
+ const _plugins = require("../plugins");
12
+ const _shared = require("../shared");
13
+ const _fs = require("fs");
14
+ const _path = require("path");
15
+ const getBaseConfig = (ctx)=>{
16
+ const { commonConfig, projectConfig, viteCmd } = ctx;
17
+ const { resolveEnvs, path } = projectConfig;
18
+ const { stage, target, flags: cmdOverrides } = viteCmd;
19
+ const NODE_ENV = target === _shared.Target.BUILD ? _shared.ViteMode.PROD : _shared.ViteMode.DEV;
20
+ const sourcemap = cmdOverrides?.[_shared.Flag.SOURCEMAP] ?? stage !== _shared.Stage.PROD;
21
+ const envPrefix = `${commonConfig.envPrefix.toUpperCase()}_`;
22
+ const omittedStages = resolveEnvs.local ? [
23
+ _shared.Stage.DEV
24
+ ] : [
25
+ _shared.Stage.DEV,
26
+ _shared.Stage.LOCAL
27
+ ];
28
+ const envPath = `environments/environment.${stage}.ts`;
29
+ const fallbackEnvPath = `environments/environment.ts`;
30
+ // Verify if the local Environment file is present
31
+ const envFilePath = (0, _fs.existsSync)((0, _path.resolve)(path, 'src', envPath)) ? envPath : fallbackEnvPath;
32
+ return {
33
+ envPrefix,
34
+ plugins: (0, _shared.getPlugins)(ctx, _plugins.basePlugins, _plugins.bundleAnalysisPlugin),
35
+ resolve: {
36
+ alias: {
37
+ ...(0, _shared.when)(resolveEnvs.default && !omittedStages.includes(stage), {
38
+ '~env': envFilePath
39
+ })
40
+ }
41
+ },
42
+ define: {
43
+ 'module.hot': false,
44
+ 'process.env.DEBUG': null,
45
+ 'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
46
+ __vite_process_env_NODE_ENV: JSON.stringify(NODE_ENV)
47
+ },
48
+ build: {
49
+ sourcemap,
50
+ minify: true,
51
+ emptyOutDir: true,
52
+ cssCodeSplit: true
53
+ }
54
+ };
55
+ };
@@ -0,0 +1,7 @@
1
+ import { ProjectType, type Context } from '../shared';
2
+ export * from './app';
3
+ export * from './base';
4
+ export * from './lib';
5
+ export * from './script';
6
+ export declare const getConfig: (ctx: Context, type?: ProjectType | null) => import("vite").UserConfig;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/configs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAMtD,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,SAAS,QAAS,OAAO,SAAQ,WAAW,GAAG,IAAI,8BAc/D,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getConfig;
9
+ }
10
+ });
11
+ const _export_star = require("@swc/helpers/_/_export_star");
12
+ const _shared = require("../shared");
13
+ const _app = _export_star._(require("./app"), exports);
14
+ const _base = _export_star._(require("./base"), exports);
15
+ const _lib = _export_star._(require("./lib"), exports);
16
+ const _script = _export_star._(require("./script"), exports);
17
+ const getConfig = (ctx, type = null)=>{
18
+ switch(type){
19
+ case _shared.ProjectType.APP:
20
+ return (0, _app.getAppConfig)(ctx);
21
+ case _shared.ProjectType.LIB:
22
+ return (0, _lib.getLibConfig)(ctx);
23
+ case _shared.ProjectType.SCRIPT:
24
+ return (0, _script.getScriptConfig)(ctx);
25
+ default:
26
+ return (0, _base.getBaseConfig)(ctx);
27
+ }
28
+ };
@@ -0,0 +1,4 @@
1
+ import type { UserConfig } from 'vite';
2
+ import { type Context } from '../shared';
3
+ export declare const getLibConfig: (ctx: Context) => UserConfig;
4
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/configs/lib.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,YAAY,QAAS,OAAO,KAAG,UA8C3C,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getLibConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getLibConfig;
9
+ }
10
+ });
11
+ const _path = require("path");
12
+ const _plugins = require("../plugins");
13
+ const _shared = require("../shared");
14
+ const getLibConfig = (ctx)=>{
15
+ const { projectConfig, commonConfig } = ctx;
16
+ const { externalizeLibGlob = [] } = commonConfig;
17
+ const { name, path, externalizeLibs } = projectConfig;
18
+ const entry = (0, _path.resolve)(path, projectConfig.entry ?? 'src/index.ts');
19
+ const defaultExternals = {
20
+ react: true,
21
+ 'react-dom': true,
22
+ 'react/jsx-runtime': true
23
+ };
24
+ // Get external dependencies based on glob patterns
25
+ const externalDeps = (0, _shared.getExternalDependencies)(path, [
26
+ ...externalizeLibGlob,
27
+ ...externalizeLibs.glob
28
+ ]);
29
+ const rollupExternal = [
30
+ ...externalDeps,
31
+ ...Object.keys((0, _shared.when)(externalizeLibs.default, defaultExternals))
32
+ ];
33
+ const rollupGlobals = {
34
+ react: 'React',
35
+ 'react-dom': 'ReactDOM',
36
+ 'react/jsx-runtime': 'ReactJsxRuntime'
37
+ };
38
+ return {
39
+ plugins: (0, _shared.getPlugins)(ctx, _plugins.dtsPlugin),
40
+ build: {
41
+ lib: {
42
+ name,
43
+ entry,
44
+ formats: [
45
+ 'es'
46
+ ],
47
+ fileName: (format)=>`index.${format === 'es' ? 'mjs' : 'cjs'}`
48
+ },
49
+ rollupOptions: {
50
+ external: rollupExternal,
51
+ output: {
52
+ globals: (0, _shared.when)(externalizeLibs.default, rollupGlobals)
53
+ }
54
+ }
55
+ }
56
+ };
57
+ };
@@ -0,0 +1,4 @@
1
+ import type { UserConfig } from 'vite';
2
+ import { type Context } from '../shared';
3
+ export declare const getScriptConfig: (ctx: Context) => UserConfig;
4
+ //# sourceMappingURL=script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/configs/script.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEhE,eAAO,MAAM,eAAe,QAAS,OAAO,KAAG,UAwB9C,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getScriptConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getScriptConfig;
9
+ }
10
+ });
11
+ const _path = require("path");
12
+ const _plugins = require("../plugins");
13
+ const _shared = require("../shared");
14
+ const getScriptConfig = (ctx)=>{
15
+ const { commonConfig, projectConfig } = ctx;
16
+ const { envPrefix } = commonConfig;
17
+ const { port } = projectConfig;
18
+ const { name, path, fileName, chunkPrefix } = projectConfig;
19
+ const entry = (0, _path.resolve)(path, projectConfig.entry ?? 'src/main');
20
+ return {
21
+ plugins: (0, _shared.getPlugins)(ctx, _plugins.injectCssIntoShadowDomPlugin, _plugins.injectCssByJsPlugin),
22
+ server: {
23
+ port,
24
+ host: true
25
+ },
26
+ build: {
27
+ lib: {
28
+ name,
29
+ entry,
30
+ fileName,
31
+ formats: [
32
+ 'es'
33
+ ]
34
+ },
35
+ rollupOptions: {
36
+ output: {
37
+ chunkFileNames: (0, _shared.chunkName)(`${envPrefix}-${chunkPrefix}`)
38
+ }
39
+ }
40
+ }
41
+ };
42
+ };
@@ -0,0 +1,3 @@
1
+ export * from './main';
2
+ export * from './shared';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vite/config-builder/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./main"), exports);
7
+ _export_star._(require("./shared"), exports);
@@ -0,0 +1,10 @@
1
+ import { type UserConfig } from 'vite';
2
+ import { type CommonProjectConfig, type ProjectConfig } from './shared';
3
+ /**
4
+ * Builds the configuration based on common and project-specific configurations.
5
+ *
6
+ * @param {CommonProjectConfig} commonConfig - The common configuration.
7
+ * @returns - Returns a function that accepts a project configuration and returns the Vite configuration.
8
+ */
9
+ export declare const createConfigBuilder: (commonConfig: CommonProjectConfig) => (projectConfig: ProjectConfig) => UserConfig;
10
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/vite/config-builder/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAGrD,OAAO,EAGL,KAAK,mBAAmB,EAExB,KAAK,aAAa,EACnB,MAAM,UAAU,CAAC;AAGlB;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iBACf,mBAAmB,qBAClB,aAAa,KAAG,UA2B/B,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "createConfigBuilder", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createConfigBuilder;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _vite = require("vite");
13
+ const _logger = /*#__PURE__*/ _interop_require_wildcard._(require("../../logger"));
14
+ const _configs = require("./configs");
15
+ const _shared = require("./shared");
16
+ const _shared1 = require("../../shared");
17
+ const createConfigBuilder = (commonConfig)=>(projectConfig)=>{
18
+ try {
19
+ const localPkgJson = (0, _shared1.getPkgJson)(projectConfig.path);
20
+ const { cfg, viteCmd } = (0, _shared.initializeConfig)(commonConfig, projectConfig, localPkgJson);
21
+ const isDebug = _logger.currentLogLevel === _logger.LogLevel.DEBUG;
22
+ const { type, overrides } = cfg;
23
+ const ctx = {
24
+ viteCmd,
25
+ localPkgJson,
26
+ commonConfig,
27
+ projectConfig: cfg
28
+ };
29
+ const defaultConfig = (0, _shared.mergeConfigs)((0, _configs.getConfig)(ctx), (0, _configs.getConfig)(ctx, type));
30
+ const config = (0, _shared.mergeConfigs)(defaultConfig, overrides);
31
+ if (isDebug) _logger.default.debug('Generated config:', config);
32
+ return (0, _vite.defineConfig)(config);
33
+ } catch (err) {
34
+ _logger.default.error('buildConfig unexpected error:');
35
+ throw err;
36
+ }
37
+ };
@@ -0,0 +1,30 @@
1
+ import { type PluginConfig } from './shared';
2
+ /**
3
+ * Base plugins configuration for apps and libs.
4
+ *
5
+ * Plugins configured:
6
+ * - vite-tsconfig-paths
7
+ * - @originjs/vite-plugin-commonjs
8
+ * - @rollup/plugin-graphql
9
+ * - @vitejs/plugin-react-swc
10
+ */
11
+ export declare const basePlugins: PluginConfig;
12
+ /**
13
+ * Plugin configuration for generating type declarations using vite-plugin-dts.
14
+ */
15
+ export declare const dtsPlugin: PluginConfig;
16
+ /**
17
+ * Plugin configuration for bundle analysis using rollup-plugin-visualizer.
18
+ */
19
+ export declare const bundleAnalysisPlugin: PluginConfig;
20
+ /**
21
+ * Plugin configuration for injecting CSS into JS files
22
+ * using vite-plugin-css-injected-by-js.
23
+ */
24
+ export declare const injectCssByJsPlugin: PluginConfig;
25
+ /**
26
+ * Plugin configuration for injecting CSS into Shadow Dom.
27
+ * using local plugin.
28
+ */
29
+ export declare const injectCssIntoShadowDomPlugin: PluginConfig;
30
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../../src/vite/config-builder/plugins.ts"],"names":[],"mappings":"AASA,OAAO,EAAmC,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE9E;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,YAsBzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,YAYvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,YASlC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAGjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,YAG1C,CAAC"}