@unisphere/cli 1.13.1

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 (205) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +17 -0
  3. package/bundler/context/rollup.js +199 -0
  4. package/bundler/package/bundled-dependencies.js +15 -0
  5. package/bundler/package/fix-package-json-dependencies.js +104 -0
  6. package/bundler/package/rollup.js +116 -0
  7. package/package.json +49 -0
  8. package/src/index.d.ts +2 -0
  9. package/src/index.js +12 -0
  10. package/src/index.js.map +1 -0
  11. package/src/lib/commands/context/activate/check-availability.d.ts +7 -0
  12. package/src/lib/commands/context/activate/check-availability.js +29 -0
  13. package/src/lib/commands/context/activate/check-availability.js.map +1 -0
  14. package/src/lib/commands/context/activate/command.d.ts +2 -0
  15. package/src/lib/commands/context/activate/command.js +16 -0
  16. package/src/lib/commands/context/activate/command.js.map +1 -0
  17. package/src/lib/commands/context/activate/element/command.d.ts +2 -0
  18. package/src/lib/commands/context/activate/element/command.js +73 -0
  19. package/src/lib/commands/context/activate/element/command.js.map +1 -0
  20. package/src/lib/commands/context/activate/loader/command.d.ts +2 -0
  21. package/src/lib/commands/context/activate/loader/command.js +55 -0
  22. package/src/lib/commands/context/activate/loader/command.js.map +1 -0
  23. package/src/lib/commands/context/activate/runtime-file-utils.d.ts +20 -0
  24. package/src/lib/commands/context/activate/runtime-file-utils.js +39 -0
  25. package/src/lib/commands/context/activate/runtime-file-utils.js.map +1 -0
  26. package/src/lib/commands/context/activate/update-runtime-version.d.ts +23 -0
  27. package/src/lib/commands/context/activate/update-runtime-version.js +78 -0
  28. package/src/lib/commands/context/activate/update-runtime-version.js.map +1 -0
  29. package/src/lib/commands/context/activate/verify-env-readiness.d.ts +8 -0
  30. package/src/lib/commands/context/activate/verify-env-readiness.js +54 -0
  31. package/src/lib/commands/context/activate/verify-env-readiness.js.map +1 -0
  32. package/src/lib/commands/context/activate/workspace/command.d.ts +2 -0
  33. package/src/lib/commands/context/activate/workspace/command.js +60 -0
  34. package/src/lib/commands/context/activate/workspace/command.js.map +1 -0
  35. package/src/lib/commands/context/build-command.d.ts +2 -0
  36. package/src/lib/commands/context/build-command.js +74 -0
  37. package/src/lib/commands/context/build-command.js.map +1 -0
  38. package/src/lib/commands/context/context-command.d.ts +2 -0
  39. package/src/lib/commands/context/context-command.js +19 -0
  40. package/src/lib/commands/context/context-command.js.map +1 -0
  41. package/src/lib/commands/context/publish/command.d.ts +2 -0
  42. package/src/lib/commands/context/publish/command.js +82 -0
  43. package/src/lib/commands/context/publish/command.js.map +1 -0
  44. package/src/lib/commands/context/publish/execute/execute.d.ts +2 -0
  45. package/src/lib/commands/context/publish/execute/execute.js +118 -0
  46. package/src/lib/commands/context/publish/execute/execute.js.map +1 -0
  47. package/src/lib/commands/context/publish/execute/sync-element.d.ts +8 -0
  48. package/src/lib/commands/context/publish/execute/sync-element.js +58 -0
  49. package/src/lib/commands/context/publish/execute/sync-element.js.map +1 -0
  50. package/src/lib/commands/context/publish/prepare/build-nx-runtimes.d.ts +11 -0
  51. package/src/lib/commands/context/publish/prepare/build-nx-runtimes.js +112 -0
  52. package/src/lib/commands/context/publish/prepare/build-nx-runtimes.js.map +1 -0
  53. package/src/lib/commands/context/publish/prepare/prepare.d.ts +2 -0
  54. package/src/lib/commands/context/publish/prepare/prepare.js +122 -0
  55. package/src/lib/commands/context/publish/prepare/prepare.js.map +1 -0
  56. package/src/lib/commands/context/publish/types.d.ts +15 -0
  57. package/src/lib/commands/context/publish/types.js +3 -0
  58. package/src/lib/commands/context/publish/types.js.map +1 -0
  59. package/src/lib/commands/context/serve-command.d.ts +2 -0
  60. package/src/lib/commands/context/serve-command.js +76 -0
  61. package/src/lib/commands/context/serve-command.js.map +1 -0
  62. package/src/lib/commands/info/command.d.ts +2 -0
  63. package/src/lib/commands/info/command.js +51 -0
  64. package/src/lib/commands/info/command.js.map +1 -0
  65. package/src/lib/commands/init/command.d.ts +2 -0
  66. package/src/lib/commands/init/command.js +46 -0
  67. package/src/lib/commands/init/command.js.map +1 -0
  68. package/src/lib/commands/package/build-command.d.ts +2 -0
  69. package/src/lib/commands/package/build-command.js +70 -0
  70. package/src/lib/commands/package/build-command.js.map +1 -0
  71. package/src/lib/commands/package/link/command.d.ts +2 -0
  72. package/src/lib/commands/package/link/command.js +110 -0
  73. package/src/lib/commands/package/link/command.js.map +1 -0
  74. package/src/lib/commands/package/package-command.d.ts +2 -0
  75. package/src/lib/commands/package/package-command.js +15 -0
  76. package/src/lib/commands/package/package-command.js.map +1 -0
  77. package/src/lib/commands/package/publish/command.d.ts +2 -0
  78. package/src/lib/commands/package/publish/command.js +37 -0
  79. package/src/lib/commands/package/publish/command.js.map +1 -0
  80. package/src/lib/commands/package/publish/deploy-to-github.d.ts +13 -0
  81. package/src/lib/commands/package/publish/deploy-to-github.js +151 -0
  82. package/src/lib/commands/package/publish/deploy-to-github.js.map +1 -0
  83. package/src/lib/commands/package/publish/deploy-to-npm.d.ts +13 -0
  84. package/src/lib/commands/package/publish/deploy-to-npm.js +151 -0
  85. package/src/lib/commands/package/publish/deploy-to-npm.js.map +1 -0
  86. package/src/lib/commands/package/publish/publish.d.ts +2 -0
  87. package/src/lib/commands/package/publish/publish.js +133 -0
  88. package/src/lib/commands/package/publish/publish.js.map +1 -0
  89. package/src/lib/commands/package/publish/types.d.ts +7 -0
  90. package/src/lib/commands/package/publish/types.js +3 -0
  91. package/src/lib/commands/package/publish/types.js.map +1 -0
  92. package/src/lib/unisphere.d.ts +2 -0
  93. package/src/lib/unisphere.js +19 -0
  94. package/src/lib/unisphere.js.map +1 -0
  95. package/src/lib/utils/artifacts.d.ts +6 -0
  96. package/src/lib/utils/artifacts.js +44 -0
  97. package/src/lib/utils/artifacts.js.map +1 -0
  98. package/src/lib/utils/aws/copy-s3-folder.d.ts +7 -0
  99. package/src/lib/utils/aws/copy-s3-folder.js +43 -0
  100. package/src/lib/utils/aws/copy-s3-folder.js.map +1 -0
  101. package/src/lib/utils/aws/download-json-from-bucket.d.ts +8 -0
  102. package/src/lib/utils/aws/download-json-from-bucket.js +42 -0
  103. package/src/lib/utils/aws/download-json-from-bucket.js.map +1 -0
  104. package/src/lib/utils/aws/get-s3-client.d.ts +2 -0
  105. package/src/lib/utils/aws/get-s3-client.js +39 -0
  106. package/src/lib/utils/aws/get-s3-client.js.map +1 -0
  107. package/src/lib/utils/aws/is-s3-file-exists.d.ts +6 -0
  108. package/src/lib/utils/aws/is-s3-file-exists.js +36 -0
  109. package/src/lib/utils/aws/is-s3-file-exists.js.map +1 -0
  110. package/src/lib/utils/aws/is-s3-folder-exists.d.ts +8 -0
  111. package/src/lib/utils/aws/is-s3-folder-exists.js +33 -0
  112. package/src/lib/utils/aws/is-s3-folder-exists.js.map +1 -0
  113. package/src/lib/utils/aws/list-s3-folders.d.ts +8 -0
  114. package/src/lib/utils/aws/list-s3-folders.js +32 -0
  115. package/src/lib/utils/aws/list-s3-folders.js.map +1 -0
  116. package/src/lib/utils/aws/mime-type-mapping.d.ts +2 -0
  117. package/src/lib/utils/aws/mime-type-mapping.js +8624 -0
  118. package/src/lib/utils/aws/mime-type-mapping.js.map +1 -0
  119. package/src/lib/utils/aws/upload-json-to-bucket.d.ts +9 -0
  120. package/src/lib/utils/aws/upload-json-to-bucket.js +31 -0
  121. package/src/lib/utils/aws/upload-json-to-bucket.js.map +1 -0
  122. package/src/lib/utils/aws/upload-to-aws-bucket.d.ts +9 -0
  123. package/src/lib/utils/aws/upload-to-aws-bucket.js +60 -0
  124. package/src/lib/utils/aws/upload-to-aws-bucket.js.map +1 -0
  125. package/src/lib/utils/github/tags.d.ts +10 -0
  126. package/src/lib/utils/github/tags.js +71 -0
  127. package/src/lib/utils/github/tags.js.map +1 -0
  128. package/src/lib/utils/listr2/create-exec-task.d.ts +8 -0
  129. package/src/lib/utils/listr2/create-exec-task.js +38 -0
  130. package/src/lib/utils/listr2/create-exec-task.js.map +1 -0
  131. package/src/lib/utils/listr2/defaults.d.ts +4 -0
  132. package/src/lib/utils/listr2/defaults.js +25 -0
  133. package/src/lib/utils/listr2/defaults.js.map +1 -0
  134. package/src/lib/utils/prompts/prompts.d.ts +24 -0
  135. package/src/lib/utils/prompts/prompts.js +184 -0
  136. package/src/lib/utils/prompts/prompts.js.map +1 -0
  137. package/src/lib/utils/prompts/vendor/prompts/elements/confirm.d.ts +19 -0
  138. package/src/lib/utils/prompts/vendor/prompts/elements/confirm.js +75 -0
  139. package/src/lib/utils/prompts/vendor/prompts/elements/confirm.js.map +1 -0
  140. package/src/lib/utils/prompts/vendor/prompts/elements/index.d.ts +4 -0
  141. package/src/lib/utils/prompts/vendor/prompts/elements/index.js +12 -0
  142. package/src/lib/utils/prompts/vendor/prompts/elements/index.js.map +1 -0
  143. package/src/lib/utils/prompts/vendor/prompts/elements/prompt.d.ts +12 -0
  144. package/src/lib/utils/prompts/vendor/prompts/elements/prompt.js +55 -0
  145. package/src/lib/utils/prompts/vendor/prompts/elements/prompt.js.map +1 -0
  146. package/src/lib/utils/prompts/vendor/prompts/elements/select.d.ts +30 -0
  147. package/src/lib/utils/prompts/vendor/prompts/elements/select.js +106 -0
  148. package/src/lib/utils/prompts/vendor/prompts/elements/select.js.map +1 -0
  149. package/src/lib/utils/prompts/vendor/prompts/elements/text.d.ts +35 -0
  150. package/src/lib/utils/prompts/vendor/prompts/elements/text.js +130 -0
  151. package/src/lib/utils/prompts/vendor/prompts/elements/text.js.map +1 -0
  152. package/src/lib/utils/prompts/vendor/prompts/index.d.ts +9 -0
  153. package/src/lib/utils/prompts/vendor/prompts/index.js +66 -0
  154. package/src/lib/utils/prompts/vendor/prompts/index.js.map +1 -0
  155. package/src/lib/utils/prompts/vendor/prompts/prompts.d.ts +27 -0
  156. package/src/lib/utils/prompts/vendor/prompts/prompts.js +52 -0
  157. package/src/lib/utils/prompts/vendor/prompts/prompts.js.map +1 -0
  158. package/src/lib/utils/prompts/vendor/prompts/util/action.d.ts +1 -0
  159. package/src/lib/utils/prompts/vendor/prompts/util/action.js +39 -0
  160. package/src/lib/utils/prompts/vendor/prompts/util/action.js.map +1 -0
  161. package/src/lib/utils/prompts/vendor/prompts/util/clear.d.ts +1 -0
  162. package/src/lib/utils/prompts/vendor/prompts/util/clear.js +17 -0
  163. package/src/lib/utils/prompts/vendor/prompts/util/clear.js.map +1 -0
  164. package/src/lib/utils/prompts/vendor/prompts/util/figures.d.ts +9 -0
  165. package/src/lib/utils/prompts/vendor/prompts/util/figures.js +21 -0
  166. package/src/lib/utils/prompts/vendor/prompts/util/figures.js.map +1 -0
  167. package/src/lib/utils/prompts/vendor/prompts/util/index.d.ts +6 -0
  168. package/src/lib/utils/prompts/vendor/prompts/util/index.js +14 -0
  169. package/src/lib/utils/prompts/vendor/prompts/util/index.js.map +1 -0
  170. package/src/lib/utils/prompts/vendor/prompts/util/strip.d.ts +1 -0
  171. package/src/lib/utils/prompts/vendor/prompts/util/strip.js +12 -0
  172. package/src/lib/utils/prompts/vendor/prompts/util/strip.js.map +1 -0
  173. package/src/lib/utils/prompts/vendor/prompts/util/style.d.ts +27 -0
  174. package/src/lib/utils/prompts/vendor/prompts/util/style.js +30 -0
  175. package/src/lib/utils/prompts/vendor/prompts/util/style.js.map +1 -0
  176. package/src/lib/utils/read-json-file.d.ts +6 -0
  177. package/src/lib/utils/read-json-file.js +19 -0
  178. package/src/lib/utils/read-json-file.js.map +1 -0
  179. package/src/lib/utils/unisphere/augment-workspace-config.d.ts +2 -0
  180. package/src/lib/utils/unisphere/augment-workspace-config.js +212 -0
  181. package/src/lib/utils/unisphere/augment-workspace-config.js.map +1 -0
  182. package/src/lib/utils/unisphere/build-unisphere-elements.d.ts +16 -0
  183. package/src/lib/utils/unisphere/build-unisphere-elements.js +67 -0
  184. package/src/lib/utils/unisphere/build-unisphere-elements.js.map +1 -0
  185. package/src/lib/utils/unisphere/find-unisphere-workspace-file.d.ts +2 -0
  186. package/src/lib/utils/unisphere/find-unisphere-workspace-file.js +35 -0
  187. package/src/lib/utils/unisphere/find-unisphere-workspace-file.js.map +1 -0
  188. package/src/lib/utils/unisphere/get-global-file.d.ts +2 -0
  189. package/src/lib/utils/unisphere/get-global-file.js +27 -0
  190. package/src/lib/utils/unisphere/get-global-file.js.map +1 -0
  191. package/src/lib/utils/unisphere/types.d.ts +88 -0
  192. package/src/lib/utils/unisphere/types.js +97 -0
  193. package/src/lib/utils/unisphere/types.js.map +1 -0
  194. package/src/lib/utils/unisphere/workspace.d.ts +5 -0
  195. package/src/lib/utils/unisphere/workspace.js +50 -0
  196. package/src/lib/utils/unisphere/workspace.js.map +1 -0
  197. package/src/lib/utils/unisphere-utils.d.ts +7 -0
  198. package/src/lib/utils/unisphere-utils.js +33 -0
  199. package/src/lib/utils/unisphere-utils.js.map +1 -0
  200. package/src/lib/utils/utils.d.ts +9 -0
  201. package/src/lib/utils/utils.js +33 -0
  202. package/src/lib/utils/utils.js.map +1 -0
  203. package/src/lib/utils/validator.d.ts +33 -0
  204. package/src/lib/utils/validator.js +109 -0
  205. package/src/lib/utils/validator.js.map +1 -0
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createListrDeployToGithubTasks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const fs = require("fs");
7
+ const execa = require("execa");
8
+ const path = require("path");
9
+ const process = require("process");
10
+ const debug_1 = require("debug");
11
+ const debug = (0, debug_1.default)('unisphere:deploy:packages:deploy-to-npm');
12
+ const createListrDeployToGithubTasks = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
+ return options.parentTask.newListr([
14
+ {
15
+ title: 'Verifying package',
16
+ task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
17
+ ctx.packageJsonPath = path.join(options.cwd, 'package.json');
18
+ if (!(0, fs_1.existsSync)(ctx.packageJsonPath)) {
19
+ throw new Error(`No package.json found in ${options.cwd}`);
20
+ }
21
+ ctx.packageJson = JSON.parse((0, fs_1.readFileSync)(ctx.packageJsonPath, 'utf8'));
22
+ if (ctx.packageJson.private) {
23
+ throw new Error(`The package in ${options.cwd} is marked as non-publishable. Set "private" to false in package.json.`);
24
+ }
25
+ }),
26
+ },
27
+ {
28
+ title: 'Configuring package.json for GitHub registry',
29
+ task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
30
+ // Add or update publishConfig
31
+ ctx.packageJson.publishConfig = {
32
+ registry: 'https://npm.pkg.github.com',
33
+ };
34
+ // Write back to package.json
35
+ yield fs.promises.writeFile(ctx.packageJsonPath, JSON.stringify(ctx.packageJson, null, 2) + '\n');
36
+ debug(`Updated package.json in ${ctx.packageJsonPath} with GitHub registry configuration`);
37
+ }),
38
+ },
39
+ {
40
+ title: 'Configuring .npmignore',
41
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
42
+ const npmignorePath = path.join(options.cwd, '.npmignore');
43
+ try {
44
+ if ((0, fs_1.existsSync)(npmignorePath)) {
45
+ const npmignoreContent = (0, fs_1.readFileSync)(npmignorePath, 'utf-8');
46
+ if (!npmignoreContent.includes('.npmrc')) {
47
+ yield fs.promises.appendFile(npmignorePath, '\n.npmrc');
48
+ debug('.npmrc entry added to .npmignore');
49
+ }
50
+ }
51
+ else {
52
+ yield fs.promises.writeFile(npmignorePath, '.npmrc\n');
53
+ debug('.npmignore file created with .npmrc entry');
54
+ }
55
+ }
56
+ catch (error) {
57
+ throw new Error(`Error updating .npmignore: ${error}`);
58
+ }
59
+ }),
60
+ },
61
+ {
62
+ title: 'Configuring .npmrc',
63
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
64
+ const npmrcPath = path.join(options.cwd, '.npmrc');
65
+ try {
66
+ const authTokenEntry = `//npm.pkg.github.com/:_authToken=${options.githubToken}`;
67
+ if ((0, fs_1.existsSync)(npmrcPath)) {
68
+ const npmrcContent = (0, fs_1.readFileSync)(npmrcPath, 'utf-8');
69
+ if (!npmrcContent.includes(authTokenEntry)) {
70
+ yield fs.promises.appendFile(npmrcPath, `\n${authTokenEntry}`);
71
+ debug('GitHub auth token added to existing .npmrc');
72
+ }
73
+ }
74
+ else {
75
+ yield fs.promises.writeFile(npmrcPath, `${authTokenEntry}\n`);
76
+ debug('.npmrc file created with GitHub auth token');
77
+ }
78
+ }
79
+ catch (error) {
80
+ throw new Error(`Error updating .npmrc: ${error}`);
81
+ }
82
+ }),
83
+ },
84
+ {
85
+ title: 'Checking if package version already exists',
86
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
87
+ try {
88
+ debug(`Checking version with token: ${options.githubToken.substring(0, 4)}...`);
89
+ debug(`Package name: ${ctx.packageJson.name}`);
90
+ const env = Object.assign(Object.assign({}, process.env), { NPM_CONFIG_REGISTRY: 'https://npm.pkg.github.com', NODE_AUTH_TOKEN: options.githubToken,
91
+ // Legacy support for some npm versions
92
+ NPM_TOKEN: options.githubToken });
93
+ const { stdout } = yield execa('npm', ['view', ctx.packageJson.name, 'versions', '--json'], {
94
+ cwd: options.cwd,
95
+ env,
96
+ });
97
+ const existingVersions = JSON.parse(stdout);
98
+ debug(`Existing versions: ${existingVersions}`);
99
+ if (existingVersions.includes(ctx.packageJson.version)) {
100
+ ctx.shouldPublish = false;
101
+ return;
102
+ }
103
+ debug(`Version ${ctx.packageJson.version} is not yet published`);
104
+ }
105
+ catch (error) {
106
+ // Enhanced error logging
107
+ debug(`Error details: ${JSON.stringify(error.message, null, 2)}`);
108
+ // If the package doesn't exist yet, npm view will fail with E404
109
+ if (!error.message.includes('E404')) {
110
+ throw new Error(`Failed to check package version: ${error.message}`);
111
+ }
112
+ debug('Package not found in registry - this is the first publication');
113
+ }
114
+ }),
115
+ },
116
+ {
117
+ title: 'Deploying package',
118
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
119
+ if (!ctx.shouldPublish) {
120
+ task.skip(`Deployment skipped because version ${ctx.packageJson.version} already exists in GitHub registry`);
121
+ return;
122
+ }
123
+ if (options.dryRun) {
124
+ debug(`Dry run: await execa('npm', ['publish'], {
125
+ cwd: ${options.cwd},
126
+ env,
127
+ });
128
+ }`);
129
+ task.skip();
130
+ }
131
+ else {
132
+ // Prepare environment variables for GitHub Packages
133
+ const env = Object.assign(Object.assign({}, process.env), { NPM_CONFIG_REGISTRY: 'https://npm.pkg.github.com', NODE_AUTH_TOKEN: options.githubToken,
134
+ // Legacy support for some npm versions
135
+ NPM_TOKEN: options.githubToken });
136
+ yield execa('npm', ['publish'], {
137
+ cwd: options.cwd,
138
+ env,
139
+ });
140
+ debug(`Package published: ${ctx.packageJson.name}@${ctx.packageJson.version}`);
141
+ }
142
+ }),
143
+ },
144
+ ], {
145
+ ctx: {
146
+ shouldPublish: true,
147
+ },
148
+ });
149
+ });
150
+ exports.createListrDeployToGithubTasks = createListrDeployToGithubTasks;
151
+ //# sourceMappingURL=deploy-to-github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-to-github.js","sourceRoot":"","sources":["../../../../../../../../packages/unisphere-cli/src/lib/commands/package/publish/deploy-to-github.ts"],"names":[],"mappings":";;;;AACA,2BAA8C;AAC9C,yBAAyB;AACzB,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAmC;AACnC,iCAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,yCAAyC,CAAC,CAAC;AAQxD,MAAM,8BAA8B,GAAG,CAAO,OAKpD,EAAE,EAAE;IACH,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,CAChC;QACE;YACE,KAAK,EAAE,mBAAmB;YAC1B,IAAI,EAAE,CAAO,GAAG,EAAE,EAAE;gBAClB,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBAC7D,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC,eAAe,CAAC,EAAE;oBACpC,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,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,CACb,oCAAoC,KAAK,CAAC,OAAO,EAAE,CACpD,CAAC;qBACH;oBACD,KAAK,CACH,+DAA+D,CAChE,CAAC;iBACH;YACH,CAAC,CAAA;SACF;QACD;YACE,KAAK,EAAE,mBAAmB;YAC1B,IAAI,EAAE,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;gBACxB,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;oBACtB,IAAI,CAAC,IAAI,CACP,sCAAsC,GAAG,CAAC,WAAW,CAAC,OAAO,oCAAoC,CAClG,CAAC;oBACF,OAAO;iBACR;gBAED,IAAI,OAAO,CAAC,MAAM,EAAE;oBAClB,KAAK,CAAC;iBACD,OAAO,CAAC,GAAG;;;UAGlB,CAAC,CAAC;oBACA,IAAI,CAAC,IAAI,EAAE,CAAC;iBACb;qBAAM;oBACL,oDAAoD;oBACpD,MAAM,GAAG,mCACJ,OAAO,CAAC,GAAG,KACd,mBAAmB,EAAE,4BAA4B,EACjD,eAAe,EAAE,OAAO,CAAC,WAAW;wBACpC,uCAAuC;wBACvC,SAAS,EAAE,OAAO,CAAC,WAAW,GAC/B,CAAC;oBAEF,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE;wBAC9B,GAAG,EAAE,OAAO,CAAC,GAAG;wBAChB,GAAG;qBACJ,CAAC,CAAC;oBAEH,KAAK,CACH,sBAAsB,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CACxE,CAAC;iBACH;YACH,CAAC,CAAA;SACF;KACF,EACD;QACE,GAAG,EAAE;YACH,aAAa,EAAE,IAAI;SACpB;KACF,CACF,CAAC;AACJ,CAAC,CAAA,CAAC;AA5LW,QAAA,8BAA8B,kCA4LzC"}
@@ -0,0 +1,13 @@
1
+ import { Listr, ListrTaskWrapper } from 'listr2';
2
+ interface Ctx {
3
+ packageJson?: any;
4
+ packageJsonPath?: string;
5
+ shouldPublish?: boolean;
6
+ }
7
+ export declare const createListrDeployToNPMTasks: (options: {
8
+ npmToken: string;
9
+ cwd: string;
10
+ dryRun: boolean;
11
+ parentTask: ListrTaskWrapper<any, any, any>;
12
+ }) => Promise<Listr<Ctx, any, any>>;
13
+ export {};
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createListrDeployToNPMTasks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const fs = require("fs");
7
+ const execa = require("execa");
8
+ const path = require("path");
9
+ const process = require("process");
10
+ const debug_1 = require("debug");
11
+ const debug = (0, debug_1.default)('unisphere:deploy:packages:deploy-to-npm');
12
+ const createListrDeployToNPMTasks = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
+ return options.parentTask.newListr([
14
+ {
15
+ title: 'Verifying package',
16
+ task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
17
+ ctx.packageJsonPath = path.join(options.cwd, 'package.json');
18
+ if (!(0, fs_1.existsSync)(ctx.packageJsonPath)) {
19
+ throw new Error(`No package.json found in ${options.cwd}`);
20
+ }
21
+ ctx.packageJson = JSON.parse((0, fs_1.readFileSync)(ctx.packageJsonPath, 'utf8'));
22
+ if (ctx.packageJson.private) {
23
+ throw new Error(`The package in ${options.cwd} is marked as non-publishable. Set "private" to false in package.json.`);
24
+ }
25
+ }),
26
+ },
27
+ {
28
+ title: 'Configuring package.json for NPM registry',
29
+ task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
30
+ // Add or update publishConfig
31
+ ctx.packageJson.publishConfig = {
32
+ registry: 'https://registry.npmjs.org',
33
+ };
34
+ // Write back to package.json
35
+ yield fs.promises.writeFile(ctx.packageJsonPath, JSON.stringify(ctx.packageJson, null, 2) + '\n');
36
+ debug(`Updated package.json in ${ctx.packageJsonPath} with NPM registry configuration`);
37
+ }),
38
+ },
39
+ {
40
+ title: 'Configuring .npmignore',
41
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
42
+ const npmignorePath = path.join(options.cwd, '.npmignore');
43
+ try {
44
+ if ((0, fs_1.existsSync)(npmignorePath)) {
45
+ const npmignoreContent = (0, fs_1.readFileSync)(npmignorePath, 'utf-8');
46
+ if (!npmignoreContent.includes('.npmrc')) {
47
+ yield fs.promises.appendFile(npmignorePath, '\n.npmrc');
48
+ debug('.npmrc entry added to .npmignore');
49
+ }
50
+ }
51
+ else {
52
+ yield fs.promises.writeFile(npmignorePath, '.npmrc\n');
53
+ debug('.npmignore file created with .npmrc entry');
54
+ }
55
+ }
56
+ catch (error) {
57
+ throw new Error(`Error updating .npmignore: ${error}`);
58
+ }
59
+ }),
60
+ },
61
+ {
62
+ title: 'Configuring .npmrc',
63
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
64
+ const npmrcPath = path.join(options.cwd, '.npmrc');
65
+ try {
66
+ const authTokenEntry = `//registry.npmjs.org/:_authToken=${options.npmToken}`;
67
+ if ((0, fs_1.existsSync)(npmrcPath)) {
68
+ const npmrcContent = (0, fs_1.readFileSync)(npmrcPath, 'utf-8');
69
+ if (!npmrcContent.includes(authTokenEntry)) {
70
+ yield fs.promises.appendFile(npmrcPath, `\n${authTokenEntry}`);
71
+ debug('NPM auth token added to existing .npmrc');
72
+ }
73
+ }
74
+ else {
75
+ yield fs.promises.writeFile(npmrcPath, `${authTokenEntry}\n`);
76
+ debug('.npmrc file created with NPM auth token');
77
+ }
78
+ }
79
+ catch (error) {
80
+ throw new Error(`Error updating .npmrc: ${error}`);
81
+ }
82
+ }),
83
+ },
84
+ {
85
+ title: 'Checking if package version already exists',
86
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
87
+ try {
88
+ debug(`Checking version with token: ${options.npmToken.substring(0, 4)}...`);
89
+ debug(`Package name: ${ctx.packageJson.name}`);
90
+ const env = Object.assign(Object.assign({}, process.env), { NPM_CONFIG_REGISTRY: 'https://registry.npmjs.org', NODE_AUTH_TOKEN: options.npmToken,
91
+ // Legacy support for some npm versions
92
+ NPM_TOKEN: options.npmToken });
93
+ const { stdout } = yield execa('npm', ['view', ctx.packageJson.name, 'versions', '--json'], {
94
+ cwd: options.cwd,
95
+ env,
96
+ });
97
+ const existingVersions = JSON.parse(stdout);
98
+ debug(`Existing versions: ${existingVersions}`);
99
+ if (existingVersions.includes(ctx.packageJson.version)) {
100
+ ctx.shouldPublish = false;
101
+ return;
102
+ }
103
+ debug(`Version ${ctx.packageJson.version} is not yet published`);
104
+ }
105
+ catch (error) {
106
+ // Enhanced error logging
107
+ debug(`Error details: ${JSON.stringify(error.message, null, 2)}`);
108
+ // If the package doesn't exist yet, npm view will fail with E404
109
+ if (!error.message.includes('E404')) {
110
+ throw new Error(`Failed to check package version: ${error.message}`);
111
+ }
112
+ debug('Package not found in registry - this is the first publication');
113
+ }
114
+ }),
115
+ },
116
+ {
117
+ title: 'Deploying package',
118
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
119
+ if (!ctx.shouldPublish) {
120
+ task.skip(`Deployment skipped because version ${ctx.packageJson.version} already exists in NPM registry`);
121
+ return;
122
+ }
123
+ if (options.dryRun) {
124
+ debug(`Dry run: await execa('npm', ['publish', '-access', 'public'], {
125
+ cwd: ${options.cwd},
126
+ env,
127
+ });
128
+ }`);
129
+ task.skip();
130
+ }
131
+ else {
132
+ // Prepare environment variables for NPM Packages
133
+ const env = Object.assign(Object.assign({}, process.env), { NPM_CONFIG_REGISTRY: 'https://registry.npmjs.org', NODE_AUTH_TOKEN: options.npmToken,
134
+ // Legacy support for some npm versions
135
+ NPM_TOKEN: options.npmToken });
136
+ yield execa('npm', ['publish', '--access', 'public'], {
137
+ cwd: options.cwd,
138
+ env,
139
+ });
140
+ debug(`Package published: ${ctx.packageJson.name}@${ctx.packageJson.version}`);
141
+ }
142
+ }),
143
+ },
144
+ ], {
145
+ ctx: {
146
+ shouldPublish: true,
147
+ },
148
+ });
149
+ });
150
+ exports.createListrDeployToNPMTasks = createListrDeployToNPMTasks;
151
+ //# sourceMappingURL=deploy-to-npm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-to-npm.js","sourceRoot":"","sources":["../../../../../../../../packages/unisphere-cli/src/lib/commands/package/publish/deploy-to-npm.ts"],"names":[],"mappings":";;;;AACA,2BAA8C;AAC9C,yBAAyB;AACzB,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAmC;AACnC,iCAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,yCAAyC,CAAC,CAAC;AAQxD,MAAM,2BAA2B,GAAG,CAAO,OAKjD,EAAE,EAAE;IACH,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,CAChC;QACE;YACE,KAAK,EAAE,mBAAmB;YAC1B,IAAI,EAAE,CAAO,GAAG,EAAE,EAAE;gBAClB,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBAC7D,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC,eAAe,CAAC,EAAE;oBACpC,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;iBAC5D;gBACD,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAC1B,IAAA,iBAAY,EAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,CAC1C,CAAC;gBAEF,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE;oBAC3B,MAAM,IAAI,KAAK,CACb,kBAAkB,OAAO,CAAC,GAAG,wEAAwE,CACtG,CAAC;iBACH;YACH,CAAC,CAAA;SACF;QACD;YACE,KAAK,EAAE,2CAA2C;YAClD,IAAI,EAAE,CAAO,GAAG,EAAE,EAAE;gBAClB,8BAA8B;gBAC9B,GAAG,CAAC,WAAW,CAAC,aAAa,GAAG;oBAC9B,QAAQ,EAAE,4BAA4B;iBACv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C,IAAI,EAAE,CAAC;iBACb;qBAAM;oBACL,iDAAiD;oBACjD,MAAM,GAAG,mCACJ,OAAO,CAAC,GAAG,KACd,mBAAmB,EAAE,4BAA4B,EACjD,eAAe,EAAE,OAAO,CAAC,QAAQ;wBACjC,uCAAuC;wBACvC,SAAS,EAAE,OAAO,CAAC,QAAQ,GAC5B,CAAC;oBAEF,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE;wBACpD,GAAG,EAAE,OAAO,CAAC,GAAG;wBAChB,GAAG;qBACJ,CAAC,CAAC;oBAEH,KAAK,CACH,sBAAsB,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CACxE,CAAC;iBACH;YACH,CAAC,CAAA;SACF;KACF,EACD;QACE,GAAG,EAAE;YACH,aAAa,EAAE,IAAI;SACpB;KACF,CACF,CAAC;AACJ,CAAC,CAAA,CAAC;AA5LW,QAAA,2BAA2B,+BA4LtC"}
@@ -0,0 +1,2 @@
1
+ import { DeployOptions } from './types';
2
+ export declare const publish: (options: DeployOptions) => Promise<void>;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publish = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = require("debug");
6
+ const workspace_1 = require("../../../utils/unisphere/workspace");
7
+ const listr2_1 = require("listr2");
8
+ const defaults_1 = require("../../../utils/listr2/defaults");
9
+ const deploy_to_github_1 = require("./deploy-to-github");
10
+ const build_unisphere_elements_1 = require("../../../utils/unisphere/build-unisphere-elements");
11
+ const deploy_to_npm_1 = require("./deploy-to-npm");
12
+ const debug = (0, debug_1.default)('unisphere:deploy:packages');
13
+ const publish = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ const unisphereWorkspace = yield (0, workspace_1.getUnisphereWorkspace)(options.cwd);
15
+ const unisphereElements = unisphereWorkspace.config.elements;
16
+ const tasks = new listr2_1.Listr([
17
+ {
18
+ title: 'Validate workspace configuration',
19
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
20
+ return task.newListr([
21
+ {
22
+ title: 'Collecting workspace packages distribution channels',
23
+ task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
24
+ const targetCounts = Object.values(unisphereElements.packages || []).reduce((acc, project) => {
25
+ if (project.distributionChannel !== 'none') {
26
+ const resolvedTarget = ['npm', 'github'].includes(project.distributionChannel)
27
+ ? project.distributionChannel
28
+ : 'other';
29
+ acc[resolvedTarget] = (acc[resolvedTarget] || 0) + 1;
30
+ }
31
+ return acc;
32
+ }, {});
33
+ ctx.deployToNpm = targetCounts['npm'] > 0;
34
+ ctx.deployToGithub = targetCounts['github'] > 0;
35
+ ctx.deployToOther = targetCounts['other'] > 0;
36
+ if (ctx.deployToOther) {
37
+ throw new Error('Unsupported distribution channel found');
38
+ }
39
+ }),
40
+ },
41
+ {
42
+ title: 'Validate tokens',
43
+ task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
44
+ if (ctx.deployToNpm && !options.npmToken) {
45
+ throw new Error('NPM token is missing');
46
+ }
47
+ if (ctx.deployToGithub && !options.githubToken) {
48
+ throw new Error('Github token is missing');
49
+ }
50
+ }),
51
+ },
52
+ ]);
53
+ }),
54
+ },
55
+ {
56
+ title: 'Deploy packages',
57
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
58
+ const packageTasks = Object.entries(unisphereElements.packages || []).map(([packageName, packageConfig]) => ({
59
+ title: `Deploy ${packageName}`,
60
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
61
+ return task.newListr([
62
+ {
63
+ title: 'Verify deployability',
64
+ skip: (ctx) => ctx.shouldSkip,
65
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
66
+ if (packageConfig.distributionChannel === 'none') {
67
+ task.title = `package has no distribution channel, skipping ${packageName} deployment`;
68
+ ctx.shouldSkip = true;
69
+ }
70
+ }),
71
+ },
72
+ {
73
+ title: 'Check github tag',
74
+ skip: (ctx) => ctx.shouldSkip,
75
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
76
+ if (!options.tagsCheck) {
77
+ task.skip();
78
+ return;
79
+ }
80
+ if (!packageConfig.hasGithubTag) {
81
+ ctx.shouldSkip = true;
82
+ task.title = `package missing github tag, skipping ${packageName} deployment`;
83
+ }
84
+ }),
85
+ },
86
+ {
87
+ title: 'Build package',
88
+ skip: (ctx) => ctx.shouldSkip,
89
+ task: (context, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
90
+ return (0, build_unisphere_elements_1.createListrForBuildingUnispherePackage)({
91
+ cwd: unisphereWorkspace.repository.repositoryRootPath,
92
+ nxProjectName: packageConfig.nxProjectName,
93
+ distFolder: packageConfig.distFolder,
94
+ production: true,
95
+ parentTask: task,
96
+ });
97
+ }),
98
+ },
99
+ {
100
+ title: `Deploy to ${packageConfig.distributionChannel}`,
101
+ skip: (ctx) => ctx.shouldSkip,
102
+ task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
103
+ if (packageConfig.distributionChannel === 'npm') {
104
+ return (0, deploy_to_npm_1.createListrDeployToNPMTasks)({
105
+ npmToken: options.npmToken,
106
+ cwd: packageConfig.distFolder,
107
+ dryRun: options.dryRun,
108
+ parentTask: task,
109
+ });
110
+ }
111
+ else if (packageConfig.distributionChannel === 'github') {
112
+ return (0, deploy_to_github_1.createListrDeployToGithubTasks)({
113
+ githubToken: options.githubToken,
114
+ cwd: packageConfig.distFolder,
115
+ dryRun: options.dryRun,
116
+ parentTask: task,
117
+ });
118
+ }
119
+ }),
120
+ },
121
+ ], {
122
+ ctx: { shouldSkip: false },
123
+ });
124
+ }),
125
+ }));
126
+ return task.newListr(packageTasks);
127
+ }),
128
+ },
129
+ ], (0, defaults_1.getDefaultListrOptions)());
130
+ yield tasks.run();
131
+ });
132
+ exports.publish = publish;
133
+ //# sourceMappingURL=publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../../../../../../packages/unisphere-cli/src/lib/commands/package/publish/publish.ts"],"names":[],"mappings":";;;;AAAA,iCAA0B;AAC1B,kEAA2E;AAE3E,mCAA+B;AAC/B,6DAAwE;AACxE,yDAAoE;AACpE,gGAA2G;AAC3G,mDAA8D;AAE9D,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,2BAA2B,CAAC,CAAC;AAE1C,MAAM,OAAO,GAAG,CAAO,OAAsB,EAAiB,EAAE;IACrE,MAAM,kBAAkB,GAAG,MAAM,IAAA,iCAAqB,EAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpE,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC;IAE7D,MAAM,KAAK,GAAG,IAAI,cAAK,CACrB;QACE;YACE,KAAK,EAAE,kCAAkC;YACzC,IAAI,EAAE,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;gBACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;oBACnB;wBACE,KAAK,EAAE,qDAAqD;wBAC5D,IAAI,EAAE,CAAO,GAAG,EAAE,EAAE;4BAClB,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAChC,iBAAiB,CAAC,QAAQ,IAAI,EAAE,CACjC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;gCACxB,IAAI,OAAO,CAAC,mBAAmB,KAAK,MAAM,EAAE;oCAC1C,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAC/C,OAAO,CAAC,mBAAmB,CAC5B;wCACC,CAAC,CAAC,OAAO,CAAC,mBAAmB;wCAC7B,CAAC,CAAC,OAAO,CAAC;oCACZ,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CA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mBAAmB,EAAE;gCACvD,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU;gCAC7B,IAAI,EAAE,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;oCACxB,IAAI,aAAa,CAAC,mBAAmB,KAAK,KAAK,EAAE;wCAC/C,OAAO,IAAA,2CAA2B,EAAC;4CACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ;4CAC1B,GAAG,EAAE,aAAa,CAAC,UAAU;4CAC7B,MAAM,EAAE,OAAO,CAAC,MAAM;4CACtB,UAAU,EAAE,IAAI;yCACjB,CAAC,CAAC;qCACJ;yCAAM,IACL,aAAa,CAAC,mBAAmB,KAAK,QAAQ,EAC9C;wCACA,OAAO,IAAA,iDAA8B,EAAC;4CACpC,WAAW,EAAE,OAAO,CAAC,WAAW;4CAChC,GAAG,EAAE,aAAa,CAAC,UAAU;4CAC7B,MAAM,EAAE,OAAO,CAAC,MAAM;4CACtB,UAAU,EAAE,IAAI;yCACjB,CAAC,CAAC;qCACJ;gCACH,CAAC,CAAA;6BACF;yBACF,EACD;4BACE,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;yBAC3B,CACF,CAAC;oBACJ,CAAC,CAAA;iBACF,CAAC,CAAC,CAAC;gBAEJ,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACrC,CAAC,CAAA;SACF;KACF,EACD,IAAA,iCAAsB,GAAE,CACzB,CAAC;IAEF,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC,CAAA,CAAC;AAxIW,QAAA,OAAO,WAwIlB"}
@@ -0,0 +1,7 @@
1
+ export interface DeployOptions {
2
+ cwd: string;
3
+ npmToken: string;
4
+ githubToken: string;
5
+ tagsCheck: boolean;
6
+ dryRun: boolean;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/unisphere-cli/src/lib/commands/package/publish/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ declare function _exports(): Promise<void>;
2
+ export = _exports;
@@ -0,0 +1,19 @@
1
+ const tslib_1 = require("tslib");
2
+ const { Command } = require('commander');
3
+ const { createContextCommand } = require('./commands/context/context-command');
4
+ const { createPackageCommand } = require('./commands/package/package-command');
5
+ const { createInfoCommand } = require('./commands/info/command');
6
+ const { createInitCommand } = require('./commands/init/command');
7
+ module.exports = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
8
+ const program = new Command();
9
+ program
10
+ .name('Kaltura UNISPHERE command line')
11
+ .description('CLI with handy Unisphere platform command lines');
12
+ program.addCommand(createContextCommand());
13
+ // program.addCommand(createGithubCommand());
14
+ program.addCommand(createPackageCommand());
15
+ program.addCommand(createInfoCommand());
16
+ program.addCommand(createInitCommand());
17
+ program.parse(process.argv);
18
+ });
19
+ //# sourceMappingURL=unisphere.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unisphere.js","sourceRoot":"","sources":["../../../../../packages/unisphere-cli/src/lib/unisphere.js"],"names":[],"mappings":";AAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACzC,MAAM,EAAE,oBAAoB,EAAC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAA;AAC7E,MAAM,EAAE,oBAAoB,EAAC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAA;AAC7E,MAAM,EAAE,iBAAiB,EAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAC/D,MAAM,EAAE,iBAAiB,EAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAE/D,MAAM,CAAC,OAAO,GAAG,GAAS,EAAE;IAC1B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACJ,IAAI,CAAC,gCAAgC,CAAC;SACtC,WAAW,CAAC,iDAAiD,CAAC,CAAA;IAEjE,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,6CAA6C;IAC7C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAA,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const getProjectArtifactsPaths: (artifactsRootFolder: string, nxProjectName: string) => Promise<{
2
+ rootPath: string;
3
+ artifactsPath: string;
4
+ statusFilePath: string;
5
+ }>;
6
+ export declare const createArtifactsFolder: (predefined?: string) => Promise<string>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createArtifactsFolder = exports.getProjectArtifactsPaths = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = require("fs-extra");
6
+ const os = require("os");
7
+ const path = require("path");
8
+ const debug_1 = require("debug");
9
+ const debug = (0, debug_1.default)('unisphere:utils');
10
+ const getRootArtifactsFolder = (predefined) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
+ // Get the system temp directory
12
+ const tempDir = os.tmpdir();
13
+ const folderPrefix = path.join(tempDir, 'unisphere/');
14
+ yield fs.ensureDir(folderPrefix);
15
+ const result = predefined
16
+ ? path.join(folderPrefix, predefined)
17
+ : yield fs.mkdtemp(path.join(folderPrefix, 'u-'));
18
+ return result;
19
+ });
20
+ const getProjectArtifactsPaths = (artifactsRootFolder, nxProjectName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
21
+ const rootFolder = path.join(artifactsRootFolder, nxProjectName);
22
+ const artifactsFolder = path.join(rootFolder, 'artifacts');
23
+ const statusFile = path.join(rootFolder, 'ready.txt');
24
+ return {
25
+ rootPath: rootFolder,
26
+ artifactsPath: artifactsFolder,
27
+ statusFilePath: statusFile,
28
+ };
29
+ });
30
+ exports.getProjectArtifactsPaths = getProjectArtifactsPaths;
31
+ const createArtifactsFolder = (predefined) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
32
+ const uniqueTempFolderPath = yield getRootArtifactsFolder(predefined);
33
+ try {
34
+ // Remove everything inside the folder
35
+ yield fs.emptyDir(uniqueTempFolderPath);
36
+ }
37
+ catch (err) {
38
+ throw new Error(`failed to clear artifacts folder ${uniqueTempFolderPath}: ${err.message}`);
39
+ }
40
+ debug(`created artifacts folder ${uniqueTempFolderPath}`);
41
+ return uniqueTempFolderPath;
42
+ });
43
+ exports.createArtifactsFolder = createArtifactsFolder;
44
+ //# sourceMappingURL=artifacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../../../../packages/unisphere-cli/src/lib/utils/artifacts.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,yBAAyB;AACzB,6BAA6B;AAC7B,iCAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,iBAAiB,CAAC,CAAC;AAEvC,MAAM,sBAAsB,GAAG,CAAO,UAAmB,EAAmB,EAAE;IAC5E,gCAAgC;IAChC,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;IAE5B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACtD,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,UAAU;QACvB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;QACrC,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA,CAAC;AAEK,MAAM,wBAAwB,GAAG,CACtC,mBAA2B,EAC3B,aAAqB,EAKpB,EAAE;IACH,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IACjE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAEtD,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,eAAe;QAC9B,cAAc,EAAE,UAAU;KAC3B,CAAC;AACJ,CAAC,CAAA,CAAC;AAjBW,QAAA,wBAAwB,4BAiBnC;AAEK,MAAM,qBAAqB,GAAG,CACnC,UAAmB,EACF,EAAE;IACnB,MAAM,oBAAoB,GAAG,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAEtE,IAAI;QACF,sCAAsC;QACtC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;KACzC;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,oCAAoC,oBAAoB,KAAK,GAAG,CAAC,OAAO,EAAE,CAC3E,CAAC;KACH;IAED,KAAK,CAAC,4BAA4B,oBAAoB,EAAE,CAAC,CAAC;IAC1D,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAA,CAAC;AAhBW,QAAA,qBAAqB,yBAgBhC"}
@@ -0,0 +1,7 @@
1
+ export declare function copyS3Folder(options: {
2
+ bucket: string;
3
+ sourcePrefix: string;
4
+ targetPrefix: string;
5
+ awsRegion: string;
6
+ awsArn?: string;
7
+ }): Promise<void>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyS3Folder = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const client_s3_1 = require("@aws-sdk/client-s3");
6
+ const get_s3_client_1 = require("./get-s3-client");
7
+ const debug_1 = require("debug");
8
+ const debug = (0, debug_1.default)('unisphere:aws:is-s3-file-exists');
9
+ function copyS3Folder(options) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ const { bucket, sourcePrefix, targetPrefix, awsRegion, awsArn } = options;
12
+ debug(`Copying S3 folder: ${bucket}/${sourcePrefix} to ${bucket}/${targetPrefix}`);
13
+ const s3 = yield (0, get_s3_client_1.getS3Client)(awsRegion, awsArn);
14
+ try {
15
+ // List all objects under the source prefix
16
+ const listParams = {
17
+ Bucket: bucket,
18
+ Prefix: sourcePrefix,
19
+ };
20
+ const objects = yield s3.send(new client_s3_1.ListObjectsV2Command(listParams));
21
+ if (!objects.Contents || objects.Contents.length === 0) {
22
+ throw new Error('No files found in the source folder.');
23
+ }
24
+ // Copy each object to the target prefix
25
+ for (const object of objects.Contents) {
26
+ const copySource = `${bucket}/${object.Key}`;
27
+ const targetKey = object.Key.replace(sourcePrefix, targetPrefix);
28
+ const copyParams = {
29
+ Bucket: bucket,
30
+ CopySource: copySource,
31
+ Key: targetKey,
32
+ };
33
+ yield s3.send(new client_s3_1.CopyObjectCommand(copyParams));
34
+ debug(`Copied ${object.Key} to ${targetKey}`);
35
+ }
36
+ }
37
+ catch (err) {
38
+ throw new Error(`Error copying files: ${err}`);
39
+ }
40
+ });
41
+ }
42
+ exports.copyS3Folder = copyS3Folder;
43
+ //# sourceMappingURL=copy-s3-folder.js.map