@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.
Files changed (251) hide show
  1. package/dist/cjs/executors/deploy/helpers.cjs +26 -0
  2. package/dist/cjs/executors/deploy/helpers.d.cts +4 -0
  3. package/dist/cjs/executors/deploy/index.cjs +22 -0
  4. package/dist/cjs/executors/deploy/index.d.cts +11 -0
  5. package/dist/cjs/executors/environments/helpers.cjs +63 -0
  6. package/dist/{src/executors/environments/helpers.d.ts → cjs/executors/environments/helpers.d.cts} +4 -4
  7. package/dist/cjs/executors/environments/index.cjs +54 -0
  8. package/dist/{src/executors/environments/executor.d.ts → cjs/executors/environments/index.d.cts} +5 -5
  9. package/dist/cjs/executors/publish/helpers.cjs +51 -0
  10. package/dist/{src/executors/publish/helpers.d.ts → cjs/executors/publish/helpers.d.cts} +3 -3
  11. package/dist/cjs/executors/publish/index.cjs +53 -0
  12. package/dist/cjs/executors/publish/index.d.cts +12 -0
  13. package/dist/cjs/executors/shared/utils.cjs +78 -0
  14. package/dist/cjs/executors/shared/utils.d.cts +34 -0
  15. package/dist/cjs/executors/update-executors-file/helpers.cjs +64 -0
  16. package/dist/cjs/executors/update-executors-file/helpers.d.cts +17 -0
  17. package/dist/cjs/executors/update-executors-file/index.cjs +41 -0
  18. package/dist/{src/executors/update-executors-file/executor.d.ts → cjs/executors/update-executors-file/index.d.cts} +5 -5
  19. package/dist/cjs/executors/vtex-link/constants.cjs +9 -0
  20. package/dist/cjs/executors/vtex-link/constants.d.cts +4 -0
  21. package/dist/cjs/executors/vtex-link/helpers.cjs +206 -0
  22. package/dist/{src/executors/vtex-link/helpers.d.ts → cjs/executors/vtex-link/helpers.d.cts} +15 -15
  23. package/dist/cjs/executors/vtex-link/index.cjs +30 -0
  24. package/dist/cjs/executors/vtex-link/index.d.cts +5 -0
  25. package/dist/cjs/index-0ce2daf7.d.ts +2 -0
  26. package/dist/cjs/index-17143e35.d.ts +2 -0
  27. package/dist/cjs/index-3080371d.d.ts +3 -0
  28. package/dist/cjs/index-f6330edc.d.ts +2 -0
  29. package/dist/cjs/index.cjs +59 -0
  30. package/dist/cjs/index.d.cts +10 -0
  31. package/dist/cjs/index.d.cts.map +1 -0
  32. package/dist/cjs/scripts/changeset-pre-mode.cjs +41 -0
  33. package/dist/cjs/scripts/changeset-pre-mode.d.cts +2 -0
  34. package/dist/cjs/shared/logger.cjs +98 -0
  35. package/dist/{src/logger.d.ts → cjs/shared/logger.d.cts} +5 -6
  36. package/dist/cjs/shared/utils.cjs +25 -0
  37. package/dist/{src/shared/utils.d.ts → cjs/shared/utils.d.cts} +2 -2
  38. package/dist/{src/executors/vtex-link/types.d.ts → cjs/types-1282e639.d.ts} +3 -3
  39. package/dist/cjs/types-7377dcc9.d.ts +4 -0
  40. package/dist/cjs/types-763439e4.d.ts +14 -0
  41. package/dist/cjs/vite/config-builder/configs/app.cjs +13 -0
  42. package/dist/cjs/vite/config-builder/configs/app.d.cts +4 -0
  43. package/dist/cjs/vite/config-builder/configs/base.cjs +57 -0
  44. package/dist/cjs/vite/config-builder/configs/base.d.cts +4 -0
  45. package/dist/cjs/vite/config-builder/configs/index.cjs +36 -0
  46. package/dist/cjs/vite/config-builder/configs/index.d.cts +7 -0
  47. package/dist/cjs/vite/config-builder/configs/lib.cjs +57 -0
  48. package/dist/cjs/vite/config-builder/configs/lib.d.cts +4 -0
  49. package/dist/cjs/vite/config-builder/configs/script.cjs +45 -0
  50. package/dist/cjs/vite/config-builder/configs/script.d.cts +4 -0
  51. package/dist/cjs/vite/config-builder/main.cjs +43 -0
  52. package/dist/cjs/vite/config-builder/main.d.cts +10 -0
  53. package/dist/cjs/vite/config-builder/plugins.cjs +95 -0
  54. package/dist/{src/vite/config-builder/plugins.d.ts → cjs/vite/config-builder/plugins.d.cts} +7 -7
  55. package/dist/cjs/vite/config-builder/shared/types.cjs +33 -0
  56. package/dist/{src/vite/config-builder/shared/types.d.ts → cjs/vite/config-builder/shared/types.d.cts} +17 -17
  57. package/dist/cjs/vite/config-builder/shared/utils/helpers.cjs +124 -0
  58. package/dist/{src/vite/config-builder/shared/utils/helpers.d.ts → cjs/vite/config-builder/shared/utils/helpers.d.cts} +10 -10
  59. package/dist/cjs/vite/config-builder/shared/utils/projectConfig.cjs +114 -0
  60. package/dist/{src/vite/config-builder/shared/utils/projectConfig.d.ts → cjs/vite/config-builder/shared/utils/projectConfig.d.cts} +8 -8
  61. package/dist/cjs/vite/config-builder/shared/utils/viteCommand.cjs +59 -0
  62. package/dist/{src/vite/config-builder/shared/utils/viteCommand.d.ts → cjs/vite/config-builder/shared/utils/viteCommand.d.cts} +4 -4
  63. package/dist/{src/vite/plugins/shadow-dom-inject-css/index.js → cjs/vite/plugins/shadow-dom-inject-css/index.cjs} +4 -19
  64. package/dist/cjs/vite/plugins/shadow-dom-inject-css/index.d.cts +7 -0
  65. package/dist/{src/vite/plugins/third-party-css-inject/main.js → cjs/vite/plugins/third-party-css-inject/main.cjs} +13 -14
  66. package/dist/cjs/vite/plugins/third-party-css-inject/main.d.cts +17 -0
  67. package/dist/{src/vite/plugins/third-party-css-inject/utils.js → cjs/vite/plugins/third-party-css-inject/utils.cjs} +8 -20
  68. package/dist/cjs/vite/plugins/third-party-css-inject/utils.d.cts +5 -0
  69. package/dist/esm/executors/deploy/helpers.d.mts +4 -0
  70. package/dist/esm/executors/deploy/helpers.mjs +22 -0
  71. package/dist/esm/executors/deploy/index.d.mts +11 -0
  72. package/dist/esm/executors/deploy/index.mjs +20 -0
  73. package/dist/esm/executors/deploy/schema.json +41 -0
  74. package/dist/esm/executors/environments/helpers.d.mts +21 -0
  75. package/dist/esm/executors/environments/helpers.mjs +59 -0
  76. package/dist/esm/executors/environments/index.d.mts +16 -0
  77. package/dist/{src/executors/environments/executor.js → esm/executors/environments/index.mjs} +23 -30
  78. package/dist/esm/executors/environments/schema.json +9 -0
  79. package/dist/esm/executors/publish/helpers.d.mts +19 -0
  80. package/dist/esm/executors/publish/helpers.mjs +48 -0
  81. package/dist/esm/executors/publish/index.d.mts +12 -0
  82. package/dist/esm/executors/publish/index.mjs +51 -0
  83. package/dist/esm/executors/publish/schema.json +19 -0
  84. package/dist/esm/executors/shared/utils.d.mts +34 -0
  85. package/dist/esm/executors/shared/utils.mjs +72 -0
  86. package/dist/esm/executors/update-executors-file/helpers.d.mts +17 -0
  87. package/dist/esm/executors/update-executors-file/helpers.mjs +59 -0
  88. package/dist/esm/executors/update-executors-file/index.d.mts +12 -0
  89. package/dist/esm/executors/update-executors-file/index.mjs +39 -0
  90. package/dist/esm/executors/update-executors-file/schema.json +9 -0
  91. package/dist/esm/executors/vtex-link/constants.d.mts +4 -0
  92. package/dist/esm/executors/vtex-link/constants.mjs +5 -0
  93. package/dist/esm/executors/vtex-link/helpers.d.mts +77 -0
  94. package/dist/esm/executors/vtex-link/helpers.mjs +192 -0
  95. package/dist/esm/executors/vtex-link/index.d.mts +5 -0
  96. package/dist/esm/executors/vtex-link/index.mjs +28 -0
  97. package/dist/esm/executors/vtex-link/schema.json +25 -0
  98. package/dist/esm/index-0ce2daf7.d.ts +2 -0
  99. package/dist/esm/index-17143e35.d.ts +2 -0
  100. package/dist/esm/index-3080371d.d.ts +3 -0
  101. package/dist/esm/index-f6330edc.d.ts +2 -0
  102. package/dist/esm/index.d.mts +10 -0
  103. package/dist/esm/index.d.mts.map +1 -0
  104. package/dist/esm/index.mjs +13 -0
  105. package/dist/esm/scripts/changeset-pre-mode.d.mts +2 -0
  106. package/dist/esm/scripts/changeset-pre-mode.mjs +39 -0
  107. package/dist/esm/shared/logger.d.mts +33 -0
  108. package/dist/{src/logger.js → esm/shared/logger.mjs} +28 -39
  109. package/dist/esm/shared/utils.d.mts +11 -0
  110. package/dist/esm/shared/utils.mjs +23 -0
  111. package/dist/esm/types-1282e639.d.ts +12 -0
  112. package/dist/esm/types-7377dcc9.d.ts +4 -0
  113. package/dist/esm/types-763439e4.d.ts +14 -0
  114. package/dist/esm/vite/config-builder/configs/app.d.mts +4 -0
  115. package/dist/esm/vite/config-builder/configs/app.mjs +11 -0
  116. package/dist/esm/vite/config-builder/configs/base.d.mts +4 -0
  117. package/dist/{src/vite/config-builder/configs/base.js → esm/vite/config-builder/configs/base.mjs} +22 -22
  118. package/dist/esm/vite/config-builder/configs/index.d.mts +7 -0
  119. package/dist/esm/vite/config-builder/configs/index.mjs +30 -0
  120. package/dist/esm/vite/config-builder/configs/lib.d.mts +4 -0
  121. package/dist/{src/vite/config-builder/configs/lib.js → esm/vite/config-builder/configs/lib.mjs} +16 -18
  122. package/dist/esm/vite/config-builder/configs/script.d.mts +4 -0
  123. package/dist/esm/vite/config-builder/configs/script.mjs +43 -0
  124. package/dist/esm/vite/config-builder/main.d.mts +10 -0
  125. package/dist/esm/vite/config-builder/main.mjs +41 -0
  126. package/dist/esm/vite/config-builder/plugins.d.mts +30 -0
  127. package/dist/esm/vite/config-builder/plugins.mjs +89 -0
  128. package/dist/esm/vite/config-builder/shared/types.d.mts +155 -0
  129. package/dist/{src/vite/config-builder/shared/types.js → esm/vite/config-builder/shared/types.mjs} +2 -27
  130. package/dist/esm/vite/config-builder/shared/utils/helpers.d.mts +81 -0
  131. package/dist/esm/vite/config-builder/shared/utils/helpers.mjs +98 -0
  132. package/dist/esm/vite/config-builder/shared/utils/projectConfig.d.mts +60 -0
  133. package/dist/esm/vite/config-builder/shared/utils/projectConfig.mjs +109 -0
  134. package/dist/esm/vite/config-builder/shared/utils/viteCommand.d.mts +24 -0
  135. package/dist/esm/vite/config-builder/shared/utils/viteCommand.mjs +56 -0
  136. package/dist/esm/vite/plugins/shadow-dom-inject-css/index.d.mts +7 -0
  137. package/dist/esm/vite/plugins/shadow-dom-inject-css/index.mjs +27 -0
  138. package/dist/esm/vite/plugins/third-party-css-inject/main.d.mts +17 -0
  139. package/dist/esm/vite/plugins/third-party-css-inject/main.mjs +45 -0
  140. package/dist/esm/vite/plugins/third-party-css-inject/utils.d.mts +5 -0
  141. package/dist/esm/vite/plugins/third-party-css-inject/utils.mjs +97 -0
  142. package/dist/executors.json +29 -0
  143. package/package.json +37 -5
  144. package/dist/package.json +0 -13
  145. package/dist/src/executors/deploy/executor.d.ts +0 -11
  146. package/dist/src/executors/deploy/executor.d.ts.map +0 -1
  147. package/dist/src/executors/deploy/executor.js +0 -27
  148. package/dist/src/executors/deploy/helpers.d.ts +0 -4
  149. package/dist/src/executors/deploy/helpers.d.ts.map +0 -1
  150. package/dist/src/executors/deploy/helpers.js +0 -40
  151. package/dist/src/executors/environments/executor.d.ts.map +0 -1
  152. package/dist/src/executors/environments/helpers.d.ts.map +0 -1
  153. package/dist/src/executors/environments/helpers.js +0 -63
  154. package/dist/src/executors/publish/executor.d.ts +0 -12
  155. package/dist/src/executors/publish/executor.d.ts.map +0 -1
  156. package/dist/src/executors/publish/executor.js +0 -58
  157. package/dist/src/executors/publish/helpers.d.ts.map +0 -1
  158. package/dist/src/executors/publish/helpers.js +0 -52
  159. package/dist/src/executors/shared/index.d.ts +0 -3
  160. package/dist/src/executors/shared/index.d.ts.map +0 -1
  161. package/dist/src/executors/shared/index.js +0 -7
  162. package/dist/src/executors/shared/types.d.ts +0 -4
  163. package/dist/src/executors/shared/types.d.ts.map +0 -1
  164. package/dist/src/executors/shared/types.js +0 -4
  165. package/dist/src/executors/shared/utils.d.ts +0 -34
  166. package/dist/src/executors/shared/utils.d.ts.map +0 -1
  167. package/dist/src/executors/shared/utils.js +0 -78
  168. package/dist/src/executors/update-executors-file/executor.d.ts.map +0 -1
  169. package/dist/src/executors/update-executors-file/executor.js +0 -46
  170. package/dist/src/executors/update-executors-file/helpers.d.ts +0 -24
  171. package/dist/src/executors/update-executors-file/helpers.d.ts.map +0 -1
  172. package/dist/src/executors/update-executors-file/helpers.js +0 -70
  173. package/dist/src/executors/update-executors-file/types.d.ts +0 -14
  174. package/dist/src/executors/update-executors-file/types.d.ts.map +0 -1
  175. package/dist/src/executors/update-executors-file/types.js +0 -4
  176. package/dist/src/executors/vtex-link/constants.d.ts +0 -4
  177. package/dist/src/executors/vtex-link/constants.d.ts.map +0 -1
  178. package/dist/src/executors/vtex-link/constants.js +0 -24
  179. package/dist/src/executors/vtex-link/executor.d.ts +0 -5
  180. package/dist/src/executors/vtex-link/executor.d.ts.map +0 -1
  181. package/dist/src/executors/vtex-link/executor.js +0 -35
  182. package/dist/src/executors/vtex-link/helpers.d.ts.map +0 -1
  183. package/dist/src/executors/vtex-link/helpers.js +0 -187
  184. package/dist/src/executors/vtex-link/types.d.ts.map +0 -1
  185. package/dist/src/executors/vtex-link/types.js +0 -4
  186. package/dist/src/index.d.ts +0 -2
  187. package/dist/src/index.d.ts.map +0 -1
  188. package/dist/src/index.js +0 -6
  189. package/dist/src/logger.d.ts.map +0 -1
  190. package/dist/src/scripts/changeset-pre-mode.d.ts +0 -2
  191. package/dist/src/scripts/changeset-pre-mode.d.ts.map +0 -1
  192. package/dist/src/scripts/changeset-pre-mode.js +0 -41
  193. package/dist/src/shared/index.d.ts +0 -2
  194. package/dist/src/shared/index.d.ts.map +0 -1
  195. package/dist/src/shared/index.js +0 -6
  196. package/dist/src/shared/utils.d.ts.map +0 -1
  197. package/dist/src/shared/utils.js +0 -22
  198. package/dist/src/vite/config-builder/configs/app.d.ts +0 -4
  199. package/dist/src/vite/config-builder/configs/app.d.ts.map +0 -1
  200. package/dist/src/vite/config-builder/configs/app.js +0 -19
  201. package/dist/src/vite/config-builder/configs/base.d.ts +0 -4
  202. package/dist/src/vite/config-builder/configs/base.d.ts.map +0 -1
  203. package/dist/src/vite/config-builder/configs/index.d.ts +0 -7
  204. package/dist/src/vite/config-builder/configs/index.d.ts.map +0 -1
  205. package/dist/src/vite/config-builder/configs/index.js +0 -28
  206. package/dist/src/vite/config-builder/configs/lib.d.ts +0 -4
  207. package/dist/src/vite/config-builder/configs/lib.d.ts.map +0 -1
  208. package/dist/src/vite/config-builder/configs/script.d.ts +0 -4
  209. package/dist/src/vite/config-builder/configs/script.d.ts.map +0 -1
  210. package/dist/src/vite/config-builder/configs/script.js +0 -42
  211. package/dist/src/vite/config-builder/index.d.ts +0 -3
  212. package/dist/src/vite/config-builder/index.d.ts.map +0 -1
  213. package/dist/src/vite/config-builder/index.js +0 -7
  214. package/dist/src/vite/config-builder/main.d.ts +0 -10
  215. package/dist/src/vite/config-builder/main.d.ts.map +0 -1
  216. package/dist/src/vite/config-builder/main.js +0 -37
  217. package/dist/src/vite/config-builder/plugins.d.ts.map +0 -1
  218. package/dist/src/vite/config-builder/plugins.js +0 -88
  219. package/dist/src/vite/config-builder/shared/index.d.ts +0 -3
  220. package/dist/src/vite/config-builder/shared/index.d.ts.map +0 -1
  221. package/dist/src/vite/config-builder/shared/index.js +0 -7
  222. package/dist/src/vite/config-builder/shared/types.d.ts.map +0 -1
  223. package/dist/src/vite/config-builder/shared/utils/helpers.d.ts.map +0 -1
  224. package/dist/src/vite/config-builder/shared/utils/helpers.js +0 -61
  225. package/dist/src/vite/config-builder/shared/utils/index.d.ts +0 -4
  226. package/dist/src/vite/config-builder/shared/utils/index.d.ts.map +0 -1
  227. package/dist/src/vite/config-builder/shared/utils/index.js +0 -8
  228. package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts.map +0 -1
  229. package/dist/src/vite/config-builder/shared/utils/projectConfig.js +0 -85
  230. package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts.map +0 -1
  231. package/dist/src/vite/config-builder/shared/utils/viteCommand.js +0 -54
  232. package/dist/src/vite/index.d.ts +0 -3
  233. package/dist/src/vite/index.d.ts.map +0 -1
  234. package/dist/src/vite/index.js +0 -7
  235. package/dist/src/vite/plugins/index.d.ts +0 -3
  236. package/dist/src/vite/plugins/index.d.ts.map +0 -1
  237. package/dist/src/vite/plugins/index.js +0 -7
  238. package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts +0 -8
  239. package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts.map +0 -1
  240. package/dist/src/vite/plugins/third-party-css-inject/index.d.ts +0 -4
  241. package/dist/src/vite/plugins/third-party-css-inject/index.d.ts.map +0 -1
  242. package/dist/src/vite/plugins/third-party-css-inject/index.js +0 -13
  243. package/dist/src/vite/plugins/third-party-css-inject/main.d.ts +0 -17
  244. package/dist/src/vite/plugins/third-party-css-inject/main.d.ts.map +0 -1
  245. package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts +0 -5
  246. package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts.map +0 -1
  247. /package/dist/{src → cjs}/executors/deploy/schema.json +0 -0
  248. /package/dist/{src → cjs}/executors/environments/schema.json +0 -0
  249. /package/dist/{src → cjs}/executors/publish/schema.json +0 -0
  250. /package/dist/{src → cjs}/executors/update-executors-file/schema.json +0 -0
  251. /package/dist/{src → cjs}/executors/vtex-link/schema.json +0 -0
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "Deploy executor",
5
+ "description": "",
6
+ "type": "object",
7
+ "properties": {
8
+ "s3BucketPath": {
9
+ "type": "string",
10
+ "description": "S3 BUCKET ROUTE"
11
+ },
12
+ "cloudFrontDistributionId": {
13
+ "type": "string",
14
+ "description": "Cloudfront distribution id for cache invalidation"
15
+ },
16
+ "cloudFrontInvalidationPaths": {
17
+ "type": "array",
18
+ "description": "Cloudfront path list that must be invalidated in the cache",
19
+ "items": {
20
+ "type": "string"
21
+ },
22
+ "uniqueItems": true,
23
+ "minItems": 1
24
+ },
25
+ "buildTarget": {
26
+ "type": "string",
27
+ "description": "Build command relative to the project and without the name of the project because it is not necessary"
28
+ },
29
+ "skipBuild": {
30
+ "type": "boolean",
31
+ "description": "It allows to omit the Build process and assumes that it was already done",
32
+ "default": false
33
+ }
34
+ },
35
+ "required": [
36
+ "s3BucketPath",
37
+ "cloudFrontDistributionId",
38
+ "cloudFrontInvalidationPaths",
39
+ "buildTarget"
40
+ ]
41
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Creates the content for an environment file based on the core environment path.
3
+ *
4
+ * @param {string} coreEnvPath - The path to the core environment file.
5
+ * @returns {string} The content of the environment file.
6
+ */
7
+ declare function createEnvironmentFileContent(coreEnvPath: string): Promise<string>;
8
+ /**
9
+ * Ensures that the given directory exists, creating it if it does not.
10
+ *
11
+ * @param {string} dir - The path to the directory to check/create.
12
+ */
13
+ declare function ensureDirectoryExists(dir: string): Promise<void>;
14
+ /**
15
+ * Writes environment files to the given base path if they do not already exist.
16
+ *
17
+ * @param {string} basePath - The base directory where the files should be written.
18
+ * @param {Record<string, string>} files - An object containing filenames and their respective content.
19
+ */
20
+ declare function writeFilesIfNotExist(basePath: string, files: Record<string, string>): Promise<void>;
21
+ export { createEnvironmentFileContent, ensureDirectoryExists, writeFilesIfNotExist };
@@ -0,0 +1,59 @@
1
+ import { promises } from 'fs';
2
+ import { join } from 'path';
3
+ import { logger } from '@nx/devkit';
4
+
5
+ const { mkdir, writeFile, access } = promises;
6
+ /**
7
+ * Creates the content for an environment file based on the core environment path.
8
+ *
9
+ * @param {string} coreEnvPath - The path to the core environment file.
10
+ * @returns {string} The content of the environment file.
11
+ */ async function createEnvironmentFileContent(coreEnvPath) {
12
+ return `
13
+ import { Environment } from '@nizza/core';
14
+ import coreEnvs from '${coreEnvPath}';
15
+
16
+ const config = {
17
+ ...coreEnvs,
18
+ };
19
+
20
+ export const environment: Environment<typeof config> = config;
21
+ export default environment;
22
+ `;
23
+ }
24
+ /**
25
+ * Ensures that the given directory exists, creating it if it does not.
26
+ *
27
+ * @param {string} dir - The path to the directory to check/create.
28
+ */ async function ensureDirectoryExists(dir) {
29
+ try {
30
+ await access(dir);
31
+ logger.info('✅ Directory exists.');
32
+ } catch {
33
+ logger.info('📁 Directory does not exist. Creating...');
34
+ await mkdir(dir, {
35
+ recursive: true
36
+ });
37
+ logger.info('📁 Directory created.');
38
+ }
39
+ }
40
+ /**
41
+ * Writes environment files to the given base path if they do not already exist.
42
+ *
43
+ * @param {string} basePath - The base directory where the files should be written.
44
+ * @param {Record<string, string>} files - An object containing filenames and their respective content.
45
+ */ async function writeFilesIfNotExist(basePath, files) {
46
+ await Promise.all(Object.entries(files).map(async ([filename, content])=>{
47
+ const filePath = join(basePath, filename);
48
+ try {
49
+ await access(filePath);
50
+ logger.info(`✅ The file "${filename}" already exists.`);
51
+ } catch {
52
+ logger.warn(`📝 The file "${filename}" does not exist. Creating...`);
53
+ await writeFile(filePath, content);
54
+ logger.info(`🎉 The file "${filename}" has been created.`);
55
+ }
56
+ }));
57
+ }
58
+
59
+ export { createEnvironmentFileContent, ensureDirectoryExists, writeFilesIfNotExist };
@@ -0,0 +1,16 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { ExecutorResponse } from "../../index-f6330edc.js";
3
+ interface ExecutorOptions {
4
+ }
5
+ /**
6
+ * The executor function to create environment files.
7
+ * Ensures that the directory for the environment files exists and creates the files
8
+ * if they do not exist already. Files created are 'environment.ts', 'environment.prod.ts',
9
+ * and 'environment.staging.ts'.
10
+ *
11
+ * @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
12
+ * @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
13
+ * @returns {Promise<ExecutorResponse>} The result object with a success or error status.
14
+ */
15
+ declare function runExecutor(_opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
16
+ export { ExecutorOptions, runExecutor as default };
@@ -1,25 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, /**
6
- * The executor function to create environment files.
7
- * Ensures that the directory for the environment files exists and creates the files
8
- * if they do not exist already. Files created are 'environment.ts', 'environment.prod.ts',
9
- * and 'environment.staging.ts'.
10
- *
11
- * @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
12
- * @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
13
- * @returns {Promise<ExecutorResponse>} The result object with a success or error status.
14
- */ "default", {
15
- enumerable: true,
16
- get: function() {
17
- return runExecutor;
18
- }
19
- });
20
- const _path = require("path");
21
- const _shared = require("../shared");
22
- const _helpers = require("./helpers");
1
+ import { join } from 'path';
2
+ import { getProjectConfig, ok, err } from '../shared/utils.mjs';
3
+ import { ensureDirectoryExists, createEnvironmentFileContent, writeFilesIfNotExist } from './helpers.mjs';
4
+
23
5
  const ENV_DIR = 'src/environments';
24
6
  const ENV_DEV_FILE = 'environment.ts';
25
7
  const ENV_LOCAL_FILE = 'environment.local.ts';
@@ -31,21 +13,30 @@ const environmentFiles = [
31
13
  ENV_PROD_FILE,
32
14
  ENV_STAGING_FILE
33
15
  ];
34
- async function runExecutor(_opts, ctx) {
16
+ /**
17
+ * The executor function to create environment files.
18
+ * Ensures that the directory for the environment files exists and creates the files
19
+ * if they do not exist already. Files created are 'environment.ts', 'environment.prod.ts',
20
+ * and 'environment.staging.ts'.
21
+ *
22
+ * @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
23
+ * @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
24
+ * @returns {Promise<ExecutorResponse>} The result object with a success or error status.
25
+ */ async function runExecutor(_opts, ctx) {
35
26
  try {
36
- const projectConfig = (0, _shared.getProjectConfig)(ctx);
37
- const environmentsDir = (0, _path.join)(projectConfig.root, ENV_DIR);
38
- await (0, _helpers.ensureDirectoryExists)(environmentsDir);
27
+ const projectConfig = getProjectConfig(ctx);
28
+ const environmentsDir = join(projectConfig.root, ENV_DIR);
29
+ await ensureDirectoryExists(environmentsDir);
39
30
  for (const envFileName of environmentFiles){
40
31
  const { key, path } = getEnvPath(envFileName);
41
- const content = await (0, _helpers.createEnvironmentFileContent)(path);
42
- await (0, _helpers.writeFilesIfNotExist)(environmentsDir, {
32
+ const content = await createEnvironmentFileContent(path);
33
+ await writeFilesIfNotExist(environmentsDir, {
43
34
  [key]: content
44
35
  });
45
36
  }
46
- return (0, _shared.ok)();
37
+ return ok();
47
38
  } catch (error) {
48
- return (0, _shared.err)(error, `Failed to create environment files:`);
39
+ return err(error, `Failed to create environment files:`);
49
40
  }
50
41
  }
51
42
  function getEnvPath(fileName) {
@@ -57,3 +48,5 @@ function getEnvPath(fileName) {
57
48
  path: `@nizza/core/envs/${baseFileName.replace('.ts', '')}`
58
49
  };
59
50
  }
51
+
52
+ export { runExecutor as default };
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "Environments executor",
5
+ "description": "",
6
+ "type": "object",
7
+ "properties": {},
8
+ "required": []
9
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Retrieves the version of a published package with a given name and tag.
3
+ *
4
+ * @param {string} packageName The name of the package to retrieve the version for.
5
+ * @param {string} tag The tag to retrieve the version for.
6
+ * @returns The version of the package as a string or an object containing versions for each tag.
7
+ */
8
+ declare function getPublishedPackageVersion(packageName: string, tag?: string): Promise<any>;
9
+ /**
10
+ * Checks if a package with the given name is already published and returns its version.
11
+ *
12
+ * @param {string} packageName The name of the package to check for.
13
+ * @returns An object containing the published versions of the package and a flag indicating if it is the first version.
14
+ */
15
+ declare function checkPublishedVersion(packageName: string): Promise<{
16
+ publishedVersion: any;
17
+ isFirstVersion: boolean;
18
+ }>;
19
+ export { getPublishedPackageVersion, checkPublishedVersion };
@@ -0,0 +1,48 @@
1
+ import { logger } from '@nx/devkit';
2
+ import { exec } from 'child_process';
3
+ import { promisify } from 'util';
4
+
5
+ const execAsync = promisify(exec);
6
+ /**
7
+ * Retrieves the version of a published package with a given name and tag.
8
+ *
9
+ * @param {string} packageName The name of the package to retrieve the version for.
10
+ * @param {string} tag The tag to retrieve the version for.
11
+ * @returns The version of the package as a string or an object containing versions for each tag.
12
+ */ async function getPublishedPackageVersion(packageName, tag) {
13
+ const withTag = tag ? `.${tag}` : ' --json';
14
+ const command = `npm view ${packageName} dist-tags${withTag}`;
15
+ const { stdout, stderr } = await execAsync(command);
16
+ if (stderr) {
17
+ logger.error(stderr.trim());
18
+ process.exit(1);
19
+ }
20
+ const published = stdout.trim();
21
+ return tag ? published : JSON.parse(published);
22
+ }
23
+ /**
24
+ * Checks if a package with the given name is already published and returns its version.
25
+ *
26
+ * @param {string} packageName The name of the package to check for.
27
+ * @returns An object containing the published versions of the package and a flag indicating if it is the first version.
28
+ */ async function checkPublishedVersion(packageName) {
29
+ let publishedVersion;
30
+ let isFirstVersion = false;
31
+ try {
32
+ publishedVersion = await getPublishedPackageVersion(packageName);
33
+ } catch (err) {
34
+ if (err?.message.includes('code E404')) {
35
+ isFirstVersion = true;
36
+ logger.info(`🏁 This is the first version of "${packageName}" package. \n`);
37
+ } else {
38
+ logger.error('❌ Error when checking the last published versions \n');
39
+ throw err;
40
+ }
41
+ }
42
+ return {
43
+ publishedVersion,
44
+ isFirstVersion
45
+ };
46
+ }
47
+
48
+ export { checkPublishedVersion, getPublishedPackageVersion };
@@ -0,0 +1,12 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { ExecutorResponse } from "../../index-f6330edc.js";
3
+ interface ExecutorOptions {
4
+ tag: string;
5
+ dryRun?: boolean;
6
+ }
7
+ /**
8
+ * This is a minimal script to publish package to "npm".
9
+ * Need to authenticate with NPM before running this script.
10
+ */
11
+ declare function runExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
12
+ export { ExecutorOptions, runExecutor as default };
@@ -0,0 +1,51 @@
1
+ import { logger } from '@nx/devkit';
2
+ import semver from 'semver';
3
+ import '../../shared/logger.mjs';
4
+ import { getPkgJson } from '../../shared/utils.mjs';
5
+ import { getProjectConfig, runCommand, ok, err } from '../shared/utils.mjs';
6
+ import { checkPublishedVersion } from './helpers.mjs';
7
+
8
+ /**
9
+ * This is a minimal script to publish package to "npm".
10
+ * Need to authenticate with NPM before running this script.
11
+ */ async function runExecutor(opts, ctx) {
12
+ try {
13
+ const { tag, dryRun: isDryRun } = opts;
14
+ const { root: projectRoot } = getProjectConfig(ctx);
15
+ // Read the package.json file and extract the name and version.
16
+ const packageJson = getPkgJson(projectRoot);
17
+ const { name: packageName, version: packageVersion } = packageJson;
18
+ // Check if the package has been previously published and get the published version.
19
+ const { publishedVersion, isFirstVersion } = await checkPublishedVersion(packageName);
20
+ let greaterThanTagVersion, greaterThanLatestVersion;
21
+ if (!isFirstVersion) {
22
+ // Check if the package version is greater than the latest published version for the specified tag.
23
+ greaterThanTagVersion = publishedVersion?.[tag] ? semver.gt(packageVersion, publishedVersion?.[tag]) : true;
24
+ // Check if the package version is greater than the latest published version.
25
+ greaterThanLatestVersion = semver.gt(packageVersion, publishedVersion.latest);
26
+ console.log(`🔎 package.json version: ${packageVersion}`);
27
+ console.log('🔺 published versions:');
28
+ Object.entries(publishedVersion).forEach(([k, v])=>console.log(` * ${k}: ${v}`));
29
+ console.log('\n');
30
+ }
31
+ // Publish the package if it's the first version or if it's a new version.
32
+ const needsPublish = isFirstVersion || greaterThanLatestVersion && greaterThanTagVersion;
33
+ if (needsPublish) {
34
+ const dryRun = isDryRun ? '--dry-run' : '';
35
+ const commandToPublish = `pnpm publish --access public --tag ${tag} --no-git-checks ${dryRun}`;
36
+ isDryRun && logger.info('👀 Skip publish (dry run) \n');
37
+ logger.info(`${commandToPublish} \n`);
38
+ // Execute the command to publish the package.
39
+ // process.chdir(projectRoot);
40
+ await runCommand(commandToPublish, projectRoot);
41
+ logger.info(`\n🚀 Successfully published ${packageName}@${packageVersion}`);
42
+ } else {
43
+ logger.warn(`👻 Package version "${packageVersion}" is invalid.`);
44
+ }
45
+ return ok();
46
+ } catch (error) {
47
+ return err(error, '❌ Error when publishing the package');
48
+ }
49
+ }
50
+
51
+ export { runExecutor as default };
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "Publish executor",
5
+ "description": "",
6
+ "type": "object",
7
+ "properties": {
8
+ "tag": {
9
+ "type": "string",
10
+ "description": "Tag name to publish"
11
+ },
12
+ "dryRun": {
13
+ "type": "boolean",
14
+ "description": "Indicates whether a test execution should be done without really publishing",
15
+ "default": false
16
+ }
17
+ },
18
+ "required": ["tag"]
19
+ }
@@ -0,0 +1,34 @@
1
+ import { ExecutorContext, ProjectConfiguration } from '@nx/devkit';
2
+ import { ExecutorResponse } from "../../types-7377dcc9.js";
3
+ /**
4
+ * Indicates a successful executor operation.
5
+ *
6
+ * @param {string} message - Optional message to log for the success case.
7
+ * @returns {ExecutorResponse} - An object representing a successful operation.
8
+ */
9
+ declare function ok(message?: string): ExecutorResponse;
10
+ /**
11
+ * Indicates a failed executor operation.
12
+ *
13
+ * @param {string | Error | unknown} err - An optional error object or message indicating the nature of the failure.
14
+ * @param {string} message - An optional message to log for the error case. If not provided, a default error message is logged.
15
+ * @returns {ExecutorResponse} - An object representing a failed operation.
16
+ */
17
+ declare function err(err?: string | Error | unknown, message?: string): ExecutorResponse;
18
+ /**
19
+ * Generates a random alphanumeric identifier of a specified length.
20
+ *
21
+ * @param {number} [length=8] - The length of the identifier to generate. Defaults to 8 if not specified.
22
+ * @returns {string} - A string representing a unique identifier.
23
+ */
24
+ declare function shortId(length?: number): string;
25
+ /**
26
+ * Retrieves the project configuration for the current execution context.
27
+ *
28
+ * @param {ExecutorContext} ctx - The execution context containing project information.
29
+ * @returns {ProjectConfiguration} - The configuration object for the current project.
30
+ * @throws {Error} If the project configuration is invalid or not found.
31
+ */
32
+ declare function getProjectConfig(ctx: ExecutorContext): ProjectConfiguration;
33
+ declare function runCommand(command: string, cwd?: string | URL): Promise<void>;
34
+ export { ok, err, shortId, getProjectConfig, runCommand };
@@ -0,0 +1,72 @@
1
+ import { logger } from '@nx/devkit';
2
+ import { randomBytes } from 'crypto';
3
+ import { exec } from 'child_process';
4
+ import { promisify } from 'util';
5
+
6
+ const execAsync = promisify(exec);
7
+ /**
8
+ * Indicates a successful executor operation.
9
+ *
10
+ * @param {string} message - Optional message to log for the success case.
11
+ * @returns {ExecutorResponse} - An object representing a successful operation.
12
+ */ function ok(message) {
13
+ message && logger.info(message);
14
+ return {
15
+ success: true
16
+ };
17
+ }
18
+ /**
19
+ * Indicates a failed executor operation.
20
+ *
21
+ * @param {string | Error | unknown} err - An optional error object or message indicating the nature of the failure.
22
+ * @param {string} message - An optional message to log for the error case. If not provided, a default error message is logged.
23
+ * @returns {ExecutorResponse} - An object representing a failed operation.
24
+ */ function err(err, message) {
25
+ if (message) {
26
+ logger.error(message);
27
+ } else {
28
+ logger.error(`❌ an error occurred:`);
29
+ }
30
+ if (err) logger.error(err);
31
+ return {
32
+ success: false
33
+ };
34
+ }
35
+ /**
36
+ * Generates a random alphanumeric identifier of a specified length.
37
+ *
38
+ * @param {number} [length=8] - The length of the identifier to generate. Defaults to 8 if not specified.
39
+ * @returns {string} - A string representing a unique identifier.
40
+ */ function shortId(length = 8) {
41
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
42
+ return Array.from(randomBytes(length), (b)=>chars[b % chars.length]).join('');
43
+ }
44
+ /**
45
+ * Retrieves the project configuration for the current execution context.
46
+ *
47
+ * @param {ExecutorContext} ctx - The execution context containing project information.
48
+ * @returns {ProjectConfiguration} - The configuration object for the current project.
49
+ * @throws {Error} If the project configuration is invalid or not found.
50
+ */ function getProjectConfig(ctx) {
51
+ const projectName = ctx.projectName || '';
52
+ const projectConfig = ctx.projectsConfigurations?.projects?.[projectName];
53
+ if (!projectConfig) throw new Error('Invalid project configuration.');
54
+ return projectConfig;
55
+ }
56
+ async function runCommand(command, cwd) {
57
+ try {
58
+ const { stdout, stderr } = await execAsync(command, {
59
+ ...cwd && {
60
+ cwd
61
+ }
62
+ });
63
+ logger.info(stdout);
64
+ logger.info(stderr);
65
+ } catch (error) {
66
+ logger.error(`Unexpected error running command:`);
67
+ logger.error(error);
68
+ throw error;
69
+ }
70
+ }
71
+
72
+ export { err, getProjectConfig, ok, runCommand, shortId };
@@ -0,0 +1,17 @@
1
+ import { Executors } from "../../types-763439e4.js";
2
+ declare const transformPathToRoot: (path: string) => string;
3
+ declare const transformPathToDist: (path: string) => string;
4
+ /**
5
+ * Updates the executor paths for the provided executors object.
6
+ * @param {Executors} executors - The executors object from executors.json.
7
+ * @param {boolean} toDist - Flag to determine if './dist' should be removed from paths.
8
+ * @returns - The updated executors object with transformed paths.
9
+ */
10
+ declare const updateExecutorPaths: (executors: Executors, toDist: boolean) => Executors;
11
+ /**
12
+ * Writes a JSON file asynchronously.
13
+ * @param {string} path - The file path where to write the JSON data.
14
+ * @param {any} data - The data to be written to the file.
15
+ */
16
+ declare const writeJsonFileAsync: (path: string, data: any) => Promise<void>;
17
+ export { transformPathToRoot, transformPathToDist, updateExecutorPaths, writeJsonFileAsync };
@@ -0,0 +1,59 @@
1
+ import { logger } from '@nx/devkit';
2
+ import { promises } from 'fs';
3
+ import { cond, always, T, pipe } from 'ramda';
4
+
5
+ const { writeFile } = promises;
6
+ const transformPathToRoot = (path)=>{
7
+ const distPrefix = './dist/cjs/';
8
+ const srcRegex = /^\.\/src\//;
9
+ const executorTsRegex = /executor\.ts$/;
10
+ const jsonFileRegex = /\.json$/;
11
+ const isJson = jsonFileRegex.test(path);
12
+ const changeSrcPath = (p)=>p.replace(srcRegex, distPrefix);
13
+ const changeFileName = (p)=>isJson ? p : p.replace(executorTsRegex, 'index.cjs');
14
+ return pipe(changeSrcPath, changeFileName)(path);
15
+ };
16
+ const transformPathToDist = (path)=>{
17
+ const cjsPrefix = './cjs/';
18
+ const distRegex = /^\.\/dist\/cjs\//;
19
+ return path.replace(distRegex, cjsPrefix);
20
+ };
21
+ /**
22
+ * Updates the executor paths for the provided executors object.
23
+ * @param {Executors} executors - The executors object from executors.json.
24
+ * @param {boolean} toDist - Flag to determine if './dist' should be removed from paths.
25
+ * @returns - The updated executors object with transformed paths.
26
+ */ const updateExecutorPaths = (executors, toDist)=>{
27
+ const transform = cond([
28
+ [
29
+ always(toDist),
30
+ transformPathToDist
31
+ ],
32
+ [
33
+ T,
34
+ transformPathToRoot
35
+ ]
36
+ ]);
37
+ return Object.entries(executors).reduce((updatedExecutors, [key, executor])=>{
38
+ updatedExecutors[key] = {
39
+ ...executor,
40
+ implementation: transform(executor.implementation),
41
+ schema: transform(executor.schema)
42
+ };
43
+ return updatedExecutors;
44
+ }, {});
45
+ };
46
+ /**
47
+ * Writes a JSON file asynchronously.
48
+ * @param {string} path - The file path where to write the JSON data.
49
+ * @param {any} data - The data to be written to the file.
50
+ */ const writeJsonFileAsync = async (path, data)=>{
51
+ try {
52
+ await writeFile(path, JSON.stringify(data, null, 2));
53
+ logger.info(`✅ Updated: ${path}`);
54
+ } catch (error) {
55
+ logger.error(`❌ Error writing file ${path}: ${error}`);
56
+ }
57
+ };
58
+
59
+ export { transformPathToDist, transformPathToRoot, updateExecutorPaths, writeJsonFileAsync };
@@ -0,0 +1,12 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { ExecutorResponse } from "../../index-f6330edc.js";
3
+ import { ExecutorOptions } from "../../types-763439e4.js";
4
+ /**
5
+ * Executor function to update paths in the executors.json file.
6
+ *
7
+ * @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
8
+ * @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
9
+ * @returns {Promise<ExecutorResponse>} The result object with a success or error status.
10
+ */
11
+ declare function runExecutor(_opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
12
+ export { runExecutor as default };
@@ -0,0 +1,39 @@
1
+ import { promises } from 'fs';
2
+ import { join } from 'path';
3
+ import { getProjectConfig, ok, err } from '../shared/utils.mjs';
4
+ import { updateExecutorPaths, writeJsonFileAsync } from './helpers.mjs';
5
+
6
+ const { readFile } = promises;
7
+ /**
8
+ * Executor function to update paths in the executors.json file.
9
+ *
10
+ * @param {ExecutorOptions} _opts - Executor options, currently not used but provided for future extensibility.
11
+ * @param {ExecutorContext} ctx - The executor context, providing access to the project configuration.
12
+ * @returns {Promise<ExecutorResponse>} The result object with a success or error status.
13
+ */ async function runExecutor(_opts, ctx) {
14
+ try {
15
+ const projectConfig = getProjectConfig(ctx);
16
+ const rootDir = projectConfig.root;
17
+ const executorsFilePath = join(rootDir, 'executors.json');
18
+ const distExecutorsFilePath = join(rootDir, 'dist', 'executors.json');
19
+ const originalContent = JSON.parse(await readFile(executorsFilePath, 'utf8'));
20
+ // Update paths to point to './dist/' and add '.js'
21
+ const updatedExecutors = updateExecutorPaths(originalContent.executors, false);
22
+ // Prepare the version for the dist folder by removing './dist/' from paths
23
+ const distExecutors = updateExecutorPaths(updatedExecutors, true);
24
+ // Write both files asynchronously and in parallel
25
+ await Promise.all([
26
+ writeJsonFileAsync(executorsFilePath, {
27
+ executors: updatedExecutors
28
+ }),
29
+ writeJsonFileAsync(distExecutorsFilePath, {
30
+ executors: distExecutors
31
+ })
32
+ ]);
33
+ return ok(`🚀 Executors updated successfully.`);
34
+ } catch (error) {
35
+ return err(error, `❌ Error processing file: ${error}`);
36
+ }
37
+ }
38
+
39
+ export { runExecutor as default };
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "UpdateExecutorsFile executor",
5
+ "description": "",
6
+ "type": "object",
7
+ "properties": {},
8
+ "required": []
9
+ }
@@ -0,0 +1,4 @@
1
+ declare const VTEX_PROJECT_PATH: string | undefined;
2
+ declare const ERROR_LINKING_FLAG = "[31merror\u001B[39m: App build failed";
3
+ declare const SUCCESS_LINKING_FLAG = "[32minfo\u001B[39m: App running";
4
+ export { VTEX_PROJECT_PATH, ERROR_LINKING_FLAG, SUCCESS_LINKING_FLAG };
@@ -0,0 +1,5 @@
1
+ const VTEX_PROJECT_PATH = process.env.NZ_VTEX_PROJECT;
2
+ const ERROR_LINKING_FLAG = '[31merror: App build failed';
3
+ const SUCCESS_LINKING_FLAG = '[32minfo: App running';
4
+
5
+ export { ERROR_LINKING_FLAG, SUCCESS_LINKING_FLAG, VTEX_PROJECT_PATH };