@supernovaio/cli 2.0.15 → 2.0.17

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.
@@ -8,11 +8,20 @@ export default class TemplateUpload extends SentryCommand<TemplateUploadConfig>
8
8
  static examples: string[];
9
9
  static hidden: boolean;
10
10
  static flags: {
11
+ from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
12
  workspaceId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
14
  };
13
15
  get commandId(): string;
14
16
  get configSchema(): ZodType<TemplateUploadConfig>;
15
17
  run(): Promise<void>;
18
+ private validateDockerDaemon;
19
+ private createBuildDir;
20
+ private deleteBuildDir;
21
+ private prepareBuildFolder;
22
+ private buildDockerImage;
23
+ private pushDockerImage;
24
+ private remoteTemplateBuild;
16
25
  }
17
26
  export {};
18
27
  //# sourceMappingURL=template-upload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAI9D,QAAA,MAAM,oBAAoB,gDAAe,CAAA;AAEzC,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AA2BhE,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IAC7E,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAAiD;IAC5E,OAAgB,QAAQ,WAA0D;IAClF,OAAgB,MAAM,EAAE,OAAO,CAAO;IACtC,OAAgB,KAAK;;MAGpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsGlC"}
1
+ {"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAQ9D,QAAA,MAAM,oBAAoB,gDAAe,CAAA;AAEzC,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAuBhE,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IAC7E,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAAiD;IAC5E,OAAgB,QAAQ,WAA0D;IAClF,OAAgB,MAAM,EAAE,OAAO,CAAO;IACtC,OAAgB,KAAK;;;;MAapB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAqDnB,oBAAoB;IAMlC,OAAO,CAAC,cAAc;YAIR,cAAc;YAId,kBAAkB;YAclB,gBAAgB;YAchB,eAAe;YAQf,mBAAmB;CA0BlC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5ee66120-d90c-524e-bbfc-dc8d227ecaf3")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d3e55359-6715-5b2e-a858-ae6306d18841")}catch(e){}}();
3
3
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
4
4
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5
5
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -12,15 +12,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
12
12
  import { Flags } from "@oclif/core";
13
13
  import { action } from "@oclif/core/ux";
14
14
  import { SentryTraced } from "@sentry/nestjs";
15
- import fetch from "node-fetch";
16
15
  import { exec as execCallback } from "node:child_process";
17
- import { createHash, randomUUID } from "node:crypto";
18
- import { createReadStream } from "node:fs";
19
16
  import * as fs from "node:fs/promises";
20
17
  import path from "node:path";
21
18
  import { promisify } from "node:util";
22
19
  import { z } from "zod";
20
+ import fsx from "fs-extra";
23
21
  import { commonFlags, SentryCommand } from "../types/index.js";
22
+ import { sleep } from "../utils/common.js";
23
+ import { tmpdir } from "node:os";
24
24
  const exec = promisify(execCallback);
25
25
  const TemplateUploadConfig = z.object({});
26
26
  async function fileExists(p) {
@@ -32,19 +32,17 @@ async function fileExists(p) {
32
32
  return false;
33
33
  }
34
34
  }
35
- async function computeChecksum(filePath) {
36
- return new Promise((resolve, reject) => {
37
- const hash = createHash("sha256");
38
- const stream = createReadStream(filePath);
39
- stream.on("error", reject);
40
- hash.on("error", reject);
41
- stream.on("data", chunk => hash.update(chunk));
42
- stream.on("end", () => {
43
- const digest = hash.digest("hex");
44
- resolve(digest);
45
- });
46
- });
47
- }
35
+ const dockerfile = `
36
+ FROM node:22-slim
37
+
38
+ RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*
39
+
40
+ WORKDIR /home/user
41
+
42
+ COPY . .
43
+ RUN npm i && rm .npmrc
44
+ RUN node docker-scripts/extract-private-packages.js
45
+ `;
48
46
  export default class TemplateUpload extends SentryCommand {
49
47
  static args = {};
50
48
  static description = "Upload custom prototype app sandbox template";
@@ -52,7 +50,17 @@ export default class TemplateUpload extends SentryCommand {
52
50
  static hidden = true;
53
51
  static flags = {
54
52
  ...commonFlags,
53
+ from: Flags.string({
54
+ char: "f",
55
+ description: "Directory to upload template from, defaults to the current directory",
56
+ required: false,
57
+ }),
55
58
  workspaceId: Flags.string({ char: "w", description: "Workspace ID to upload the template to", required: true }),
59
+ designSystemId: Flags.string({
60
+ char: "d",
61
+ description: "Design system ID to upload the template to",
62
+ required: true,
63
+ }),
56
64
  };
57
65
  get commandId() {
58
66
  return TemplateUpload.id;
@@ -63,19 +71,9 @@ export default class TemplateUpload extends SentryCommand {
63
71
  async run() {
64
72
  const apiClient = await this.apiClient();
65
73
  const { flags } = await this.parse();
66
- const cwd = process.cwd();
67
- const pkgPath = path.join(cwd, "package.json");
68
- const modulesPath = path.join(cwd, "node_modules");
69
- const zipPath = path.join(cwd, ".supernova-upload.zip");
70
- if (!(await fileExists(pkgPath)))
71
- this.error("package.json not found in current directory.");
72
- if (!(await fileExists(modulesPath)) || !(await fs.stat(modulesPath)).isDirectory()) {
73
- this.error(`node_modules directory not found in the current directory`);
74
- }
75
74
  let pkg;
76
75
  try {
77
- const raw = await fs.readFile(pkgPath, "utf8");
78
- pkg = JSON.parse(raw);
76
+ pkg = await readPackageJson();
79
77
  }
80
78
  catch (error) {
81
79
  if (error instanceof Error)
@@ -83,68 +81,89 @@ export default class TemplateUpload extends SentryCommand {
83
81
  else
84
82
  throw error;
85
83
  }
86
- const depNames = Object.keys(pkg.dependencies);
87
- const missing = [];
88
- await Promise.all(depNames.map(async (name) => {
89
- const depDir = path.join(modulesPath, ...name.split("/"));
90
- if (!(await fileExists(depDir))) {
91
- missing.push(name);
84
+ if (pkg.supernova?.privateDependencies) {
85
+ this.log(`Following packages will be linked as private dependencies: ${pkg.supernova.privateDependencies}`);
86
+ if (!(await fileExists(path.join(process.cwd(), ".npmrc")))) {
87
+ this.error(`CLI needs private NPM registry access to be able to bundle private dependencies.\n` +
88
+ `Please provide .npmrc file in the root directory and include neccessary access tokens.`);
92
89
  }
93
- }));
94
- if (missing.length > 0) {
95
- this.error(`Some dependencies were not found in current node modules: [${missing.join(", ")}]`);
96
- }
97
- try {
98
- await exec(`zip -9 -q -r "${zipPath}" . -x "*.zip"`);
99
90
  }
100
- catch (error) {
101
- if (error instanceof Error)
102
- this.error(`Failed to create zip archive: ${error.message}`);
103
- else
104
- throw error;
91
+ else {
92
+ this.warn(`package.json doesn't contain 'supernova.privateDependencies' declaration.`);
93
+ this.warn(`Dependencies coming from private registries will fail`);
105
94
  }
106
- if (!(await fileExists(zipPath)))
107
- this.error(`Upload zip was not produced`);
108
- const stat = await fs.stat(zipPath);
109
- const checksum = await computeChecksum(zipPath);
110
- action.start(`Uploading ${(stat.size / 1000 / 1000).toFixed(2)}MB`);
111
- const uploadResponse = await apiClient.files.upload({
112
- ownerType: "Workspace",
95
+ const buildData = await apiClient.sandboxes.builds.start({
113
96
  workspaceId: flags.workspaceId,
114
- files: [{ checksum, name: `${randomUUID()}.zip`, size: stat.size }],
97
+ designSystemId: flags.designSystemId,
98
+ name: pkg.name,
99
+ version: pkg.version,
115
100
  });
116
- if (uploadResponse.files.length === 0)
117
- this.error(`Upload endpoint returned no files`);
118
- let file = uploadResponse.files[0];
119
- if (file.pendingUpload) {
120
- const [uploadUrl] = uploadResponse.uploadUrls;
121
- if (!uploadUrl)
122
- this.error(`File is pending upload, but no upload URL was provided`);
123
- const s3UploadResponse = await fetch(uploadUrl.uploadUrl, {
124
- method: "PUT",
125
- headers: {
126
- "Content-Type": "contentType",
127
- "Content-Length": stat.size.toString(),
128
- },
129
- body: createReadStream(zipPath),
130
- });
131
- if (!s3UploadResponse.ok) {
132
- const text = await s3UploadResponse.text();
133
- throw new Error(`Upload failed with status ${s3UploadResponse.status}: ${text}`);
134
- }
135
- const finalizeResponse = await apiClient.files.finalizeUpload({
136
- ownerType: "Workspace",
137
- workspaceId: flags.workspaceId,
138
- fileIds: [uploadResponse.files[0].id],
139
- });
140
- file = finalizeResponse.files[0];
101
+ const url = imageUrl(buildData);
102
+ await this.validateDockerDaemon();
103
+ const buildDir = await this.createBuildDir();
104
+ try {
105
+ await this.prepareBuildFolder(buildDir);
106
+ await this.buildDockerImage(buildDir, url);
107
+ await this.pushDockerImage(buildDir, url);
108
+ await this.remoteTemplateBuild(apiClient, buildData.build.id);
109
+ this.log(`✅ Template has been successfully uploaded`);
141
110
  }
142
- else {
143
- this.log(`Already uploaded, skipping upload...`);
111
+ finally {
112
+ await this.deleteBuildDir(buildDir);
113
+ }
114
+ }
115
+ async validateDockerDaemon() {
116
+ await exec("docker info").catch(() => {
117
+ this.error(`Docker is not available, please start docker daemon and try again`);
118
+ });
119
+ }
120
+ createBuildDir() {
121
+ return fs.mkdtemp(path.join(tmpdir(), "supernova-template-bundle-"));
122
+ }
123
+ async deleteBuildDir(buildDir) {
124
+ await fs.rm(buildDir, { recursive: true, force: true });
125
+ }
126
+ async prepareBuildFolder(buildDir) {
127
+ await fsx.copy(process.cwd(), buildDir, {
128
+ filter(src) {
129
+ return !src.includes("node_modules/") && !src.includes(".git/") && !src.includes(".out/");
130
+ },
131
+ });
132
+ const cliSrcPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
133
+ await fsx.copy(path.join(cliSrcPath, "docker-scripts"), path.join(buildDir, "docker-scripts"));
134
+ }
135
+ async buildDockerImage(buildDir, imageUrl) {
136
+ action.start("🔨 Building docker image");
137
+ const process = exec(`docker build --progress=plain -t ${imageUrl} --pull --platform linux/amd64 -f - .`, {
138
+ cwd: buildDir,
139
+ });
140
+ process.child.stdin.write(dockerfile);
141
+ process.child.stdin.end();
142
+ await process;
143
+ action.stop("done");
144
+ }
145
+ async pushDockerImage(buildDir, imageUrl) {
146
+ action.start("⬆️ Uploading docker image to Supernova");
147
+ await exec(`docker push ${imageUrl}`, {
148
+ cwd: buildDir,
149
+ });
150
+ action.stop("done");
151
+ }
152
+ async remoteTemplateBuild(client, buildId) {
153
+ action.start("📦 Creating template with the image");
154
+ await client.sandboxes.builds.finalize(buildId);
155
+ const pollIntervalMs = 2000;
156
+ const timeoutMs = 5 * 60 * 1000;
157
+ const startTime = Date.now();
158
+ let build;
159
+ do {
160
+ await sleep(pollIntervalMs);
161
+ build = (await client.sandboxes.builds.get(buildId)).build;
162
+ } while (build.state === "Building" && Date.now() - startTime < timeoutMs);
163
+ if (build.state !== "Success") {
164
+ this.error(`Template creation failed`);
144
165
  }
145
- await fs.unlink(zipPath);
146
166
  action.stop("done");
147
- this.log(`✅ Template has been uploaded, checksum: ${file.deduplicationKey}`);
148
167
  }
149
168
  }
150
169
  __decorate([
@@ -153,5 +172,37 @@ __decorate([
153
172
  __metadata("design:paramtypes", []),
154
173
  __metadata("design:returntype", Promise)
155
174
  ], TemplateUpload.prototype, "run", null);
175
+ async function readPackageJson() {
176
+ const pkgPath = path.join(process.cwd(), "package.json");
177
+ if (!(await fileExists(pkgPath)))
178
+ throw new Error(`package.json file was not found in the current directory`);
179
+ const raw = await fs.readFile(pkgPath, "utf8");
180
+ const pkg = JSON.parse(raw);
181
+ if (typeof pkg !== "object" || pkg === null)
182
+ throw new Error(`Error parsing package.json: not a json`);
183
+ if (typeof pkg.name !== "string")
184
+ throw new Error(`Error parsing package.json: 'name' must be defined`);
185
+ if (typeof pkg.version !== "string")
186
+ throw new Error(`Error parsing package.json: 'version' must be defined`);
187
+ if (typeof pkg.dependencies !== "object" || pkg.dependencies === null)
188
+ throw new Error(`Error parsing package.json: 'dependencies' must be defined`);
189
+ if (pkg.supernova?.privateDependencies) {
190
+ const privateDependencies = pkg.supernova?.privateDependencies;
191
+ if (!Array.isArray(privateDependencies))
192
+ throw new TypeError(`supernova.privateDependencies must be an array`);
193
+ for (const [i, d] of privateDependencies.entries()) {
194
+ if (typeof d !== "string") {
195
+ throw new TypeError(`supernova.privateDependencies[${i}] must be a string`);
196
+ }
197
+ if (!pkg.dependencies[d]) {
198
+ throw new Error(`Private dependency ${d} is not listed in 'dependencies'`);
199
+ }
200
+ }
201
+ }
202
+ return pkg;
203
+ }
204
+ function imageUrl(build) {
205
+ return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`;
206
+ }
156
207
  //# sourceMappingURL=template-upload.js.map
157
- //# debugId=5ee66120-d90c-524e-bbfc-dc8d227ecaf3
208
+ //# debugId=d3e55359-6715-5b2e-a858-ae6306d18841
@@ -1 +1 @@
1
- {"version":3,"file":"template-upload.js","sources":["../../src/commands/template-upload.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport fetch from \"node-fetch\"\nimport { exec as execCallback } from \"node:child_process\"\nimport { createHash, randomUUID } from \"node:crypto\"\nimport { createReadStream } from \"node:fs\"\nimport * as fs from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { promisify } from \"node:util\"\nimport { z, ZodType } from \"zod\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nasync function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\n\nasync function computeChecksum(filePath: string) {\n return new Promise<string>((resolve, reject) => {\n const hash = createHash(\"sha256\")\n const stream = createReadStream(filePath)\n\n stream.on(\"error\", reject)\n hash.on(\"error\", reject)\n\n stream.on(\"data\", chunk => hash.update(chunk))\n stream.on(\"end\", () => {\n const digest = hash.digest(\"hex\")\n resolve(digest)\n })\n })\n}\n\nexport default class TemplateUpload extends SentryCommand<TemplateUploadConfig> {\n static override args = {}\n static override description = \"Upload custom prototype app sandbox template\"\n static override examples = [\"<%= config.bin %> <%= command.id %> TemplateUpload \"]\n static override hidden: boolean = true\n static override flags = {\n ...commonFlags,\n workspaceId: Flags.string({ char: \"w\", description: \"Workspace ID to upload the template to\", required: true }),\n }\n\n get commandId(): string {\n return TemplateUpload.id\n }\n\n get configSchema(): ZodType<TemplateUploadConfig> {\n return TemplateUploadConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const apiClient = await this.apiClient()\n const { flags } = await this.parse()\n\n const cwd = process.cwd()\n const pkgPath = path.join(cwd, \"package.json\")\n const modulesPath = path.join(cwd, \"node_modules\")\n const zipPath = path.join(cwd, \".supernova-upload.zip\")\n\n // Validate package json\n if (!(await fileExists(pkgPath))) this.error(\"package.json not found in current directory.\")\n\n // Validate node modules\n if (!(await fileExists(modulesPath)) || !(await fs.stat(modulesPath)).isDirectory()) {\n this.error(`node_modules directory not found in the current directory`)\n }\n\n // Read package json\n let pkg\n try {\n const raw = await fs.readFile(pkgPath, \"utf8\")\n pkg = JSON.parse(raw) as { dependencies: Record<string, string> }\n } catch (error) {\n if (error instanceof Error) this.error(`Failed to read or parse package.json: ${error.message}`)\n else throw error\n }\n\n // Validate dependencies are present\n const depNames = Object.keys(pkg.dependencies)\n const missing: string[] = []\n\n await Promise.all(\n depNames.map(async name => {\n const depDir = path.join(modulesPath, ...name.split(\"/\"))\n if (!(await fileExists(depDir))) {\n missing.push(name)\n }\n }),\n )\n\n if (missing.length > 0) {\n this.error(`Some dependencies were not found in current node modules: [${missing.join(\", \")}]`)\n }\n\n // 6) Create ZIP of current directory\n try {\n await exec(`zip -9 -q -r \"${zipPath}\" . -x \"*.zip\"`)\n } catch (error) {\n if (error instanceof Error) this.error(`Failed to create zip archive: ${error.message}`)\n else throw error\n }\n\n if (!(await fileExists(zipPath))) this.error(`Upload zip was not produced`)\n\n const stat = await fs.stat(zipPath)\n const checksum = await computeChecksum(zipPath)\n\n action.start(`Uploading ${(stat.size / 1000 / 1000).toFixed(2)}MB`)\n\n const uploadResponse = await apiClient.files.upload({\n ownerType: \"Workspace\",\n workspaceId: flags.workspaceId,\n files: [{ checksum, name: `${randomUUID()}.zip`, size: stat.size }],\n })\n\n if (uploadResponse.files.length === 0) this.error(`Upload endpoint returned no files`)\n\n let file = uploadResponse.files[0]\n if (file.pendingUpload) {\n const [uploadUrl] = uploadResponse.uploadUrls\n if (!uploadUrl) this.error(`File is pending upload, but no upload URL was provided`)\n\n const s3UploadResponse = await fetch(uploadUrl.uploadUrl, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"contentType\",\n \"Content-Length\": stat.size.toString(),\n },\n body: createReadStream(zipPath),\n })\n\n if (!s3UploadResponse.ok) {\n const text = await s3UploadResponse.text()\n throw new Error(`Upload failed with status ${s3UploadResponse.status}: ${text}`)\n }\n\n const finalizeResponse = await apiClient.files.finalizeUpload({\n ownerType: \"Workspace\",\n workspaceId: flags.workspaceId,\n fileIds: [uploadResponse.files[0].id],\n })\n\n file = finalizeResponse.files[0]\n } else {\n this.log(`Already uploaded, skipping upload...`)\n }\n\n await fs.unlink(zipPath)\n\n action.stop(\"done\")\n this.log(`✅ Template has been uploaded, checksum: ${file.deduplicationKey}`)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AA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CAAC;aAChC,CAAC,CAAA;YAEF,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;gBACzB,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,CAAA;gBAC1C,MAAM,IAAI,KAAK,CAAC,6BAA6B,gBAAgB,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAA;YAClF,CAAC;YAED,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;gBAC5D,SAAS,EAAE,WAAW;gBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,OAAO,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACtC,CAAC,CAAA;YAEF,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAClC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAA;QAClD,CAAC;QAED,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAExB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnB,IAAI,CAAC,GAAG,CAAC,2CAA2C,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAA;IAC9E,CAAC;;AArGY;IADZ,YAAY,EAAE;;;;yCAsGd","debug_id":"5ee66120-d90c-524e-bbfc-dc8d227ecaf3"}
1
+ {"version":3,"file":"template-upload.js","sources":["../../src/commands/template-upload.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { exec as execCallback } from \"node:child_process\"\nimport * as fs from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { promisify } from \"node:util\"\nimport { z, ZodType } from \"zod\"\nimport fsx from \"fs-extra\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nimport { DTOSandboxTemplateBuildCreateResponse, SupernovaApiClient } from \"@supernova-studio/client\"\nimport { sleep } from \"../utils/common.js\"\nimport { tmpdir } from \"node:os\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nasync function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\n\nconst dockerfile = `\nFROM node:22-slim\n\nRUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /home/user\n\nCOPY . .\nRUN npm i && rm .npmrc\nRUN node docker-scripts/extract-private-packages.js\n`\n\nexport default class TemplateUpload extends SentryCommand<TemplateUploadConfig> {\n static override args = {}\n static override description = \"Upload custom prototype app sandbox template\"\n static override examples = [\"<%= config.bin %> <%= command.id %> TemplateUpload \"]\n static override hidden: boolean = true\n static override flags = {\n ...commonFlags,\n from: Flags.string({\n char: \"f\",\n description: \"Directory to upload template from, defaults to the current directory\",\n required: false,\n }),\n workspaceId: Flags.string({ char: \"w\", description: \"Workspace ID to upload the template to\", required: true }),\n designSystemId: Flags.string({\n char: \"d\",\n description: \"Design system ID to upload the template to\",\n required: true,\n }),\n }\n\n get commandId(): string {\n return TemplateUpload.id\n }\n\n get configSchema(): ZodType<TemplateUploadConfig> {\n return TemplateUploadConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const apiClient = await this.apiClient()\n const { flags } = await this.parse()\n\n // Read package json\n let pkg\n try {\n pkg = await readPackageJson()\n } catch (error) {\n if (error instanceof Error) this.error(`Failed to read or parse package.json: ${error.message}`)\n else throw error\n }\n\n if (pkg.supernova?.privateDependencies) {\n this.log(`Following packages will be linked as private dependencies: ${pkg.supernova.privateDependencies}`)\n\n if (!(await fileExists(path.join(process.cwd(), \".npmrc\")))) {\n this.error(\n `CLI needs private NPM registry access to be able to bundle private dependencies.\\n` +\n `Please provide .npmrc file in the root directory and include neccessary access tokens.`,\n )\n }\n } else {\n this.warn(`package.json doesn't contain 'supernova.privateDependencies' declaration.`)\n this.warn(`Dependencies coming from private registries will fail`)\n }\n\n // Request build\n const buildData = await apiClient.sandboxes.builds.start({\n workspaceId: flags.workspaceId,\n designSystemId: flags.designSystemId,\n name: pkg.name,\n version: pkg.version,\n })\n\n // Build image\n const url = imageUrl(buildData)\n\n await this.validateDockerDaemon()\n const buildDir = await this.createBuildDir()\n\n try {\n await this.prepareBuildFolder(buildDir)\n await this.buildDockerImage(buildDir, url)\n await this.pushDockerImage(buildDir, url)\n await this.remoteTemplateBuild(apiClient, buildData.build.id)\n\n this.log(`✅ Template has been successfully uploaded`)\n } finally {\n await this.deleteBuildDir(buildDir)\n }\n }\n\n private async validateDockerDaemon() {\n await exec(\"docker info\").catch(() => {\n this.error(`Docker is not available, please start docker daemon and try again`)\n })\n }\n\n private createBuildDir(): Promise<string> {\n return fs.mkdtemp(path.join(tmpdir(), \"supernova-template-bundle-\"))\n }\n\n private async deleteBuildDir(buildDir: string) {\n await fs.rm(buildDir, { recursive: true, force: true })\n }\n\n private async prepareBuildFolder(buildDir: string) {\n // Move working directory to temp folder from where it will be built\n await fsx.copy(process.cwd(), buildDir, {\n filter(src) {\n return !src.includes(\"node_modules/\") && !src.includes(\".git/\") && !src.includes(\".out/\")\n },\n })\n\n // Inject Supernova scripts\n const cliSrcPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), \"..\")\n\n await fsx.copy(path.join(cliSrcPath, \"docker-scripts\"), path.join(buildDir, \"docker-scripts\"))\n }\n\n private async buildDockerImage(buildDir: string, imageUrl: string) {\n action.start(\"🔨 Building docker image\")\n\n const process = exec(`docker build --progress=plain -t ${imageUrl} --pull --platform linux/amd64 -f - .`, {\n cwd: buildDir,\n })\n process.child.stdin!.write(dockerfile)\n process.child.stdin!.end()\n\n await process\n\n action.stop(\"done\")\n }\n\n private async pushDockerImage(buildDir: string, imageUrl: string) {\n action.start(\"⬆️ Uploading docker image to Supernova\")\n await exec(`docker push ${imageUrl}`, {\n cwd: buildDir,\n })\n action.stop(\"done\")\n }\n\n private async remoteTemplateBuild(client: SupernovaApiClient, buildId: string) {\n // Poll every 2 seconds for roughly 5 minutes\n action.start(\"📦 Creating template with the image\")\n\n // Trigger remote build phase\n await client.sandboxes.builds.finalize(buildId)\n\n // Await remote build\n const pollIntervalMs = 2000\n const timeoutMs = 5 * 60 * 1000\n\n const startTime = Date.now()\n\n let build\n do {\n await sleep(pollIntervalMs)\n build = (await client.sandboxes.builds.get(buildId)).build\n } while (build.state === \"Building\" && Date.now() - startTime < timeoutMs)\n\n // Verify build state\n if (build.state !== \"Success\") {\n this.error(`Template creation failed`)\n }\n\n action.stop(\"done\")\n }\n}\n\ntype PackageJson = {\n name: string\n version: string\n dependencies: Record<string, string>\n supernova:\n | {\n privateDependencies: string[] | undefined\n }\n | undefined\n}\n\nasync function readPackageJson(): Promise<PackageJson> {\n const pkgPath = path.join(process.cwd(), \"package.json\")\n\n if (!(await fileExists(pkgPath))) throw new Error(`package.json file was not found in the current directory`)\n\n const raw = await fs.readFile(pkgPath, \"utf8\")\n const pkg = JSON.parse(raw)\n\n if (typeof pkg !== \"object\" || pkg === null) throw new Error(`Error parsing package.json: not a json`)\n\n if (typeof pkg.name !== \"string\") throw new Error(`Error parsing package.json: 'name' must be defined`)\n if (typeof pkg.version !== \"string\") throw new Error(`Error parsing package.json: 'version' must be defined`)\n if (typeof pkg.dependencies !== \"object\" || pkg.dependencies === null)\n throw new Error(`Error parsing package.json: 'dependencies' must be defined`)\n\n if (pkg.supernova?.privateDependencies) {\n const privateDependencies = pkg.supernova?.privateDependencies\n if (!Array.isArray(privateDependencies)) throw new TypeError(`supernova.privateDependencies must be an array`)\n\n for (const [i, d] of privateDependencies.entries()) {\n if (typeof d !== \"string\") {\n throw new TypeError(`supernova.privateDependencies[${i}] must be a string`)\n }\n\n if (!pkg.dependencies[d]) {\n throw new Error(`Private dependency ${d} is not listed in 'dependencies'`)\n }\n }\n }\n\n return pkg\n}\n\nfunction im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EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;cAqBzE,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAyBvD,MAAM;CAYrB"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="91403767-c5ba-5b5a-8c9b-ca768afefabf")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c88dddb-c4e4-5734-93dd-f6bf5c033b83")}catch(e){}}();
3
3
  import { Command } from "@oclif/core";
4
4
  import * as Sentry from "@sentry/node";
5
5
  import inquirer from "inquirer";
@@ -21,7 +21,9 @@ export class BaseCommand extends Command {
21
21
  }
22
22
  async init() {
23
23
  await super.init();
24
- this.log(`Using ${this.env} environment`);
24
+ if (this.env !== "production") {
25
+ this.log(`Using ${this.env} environment`);
26
+ }
25
27
  }
26
28
  async promptBrandId(designSystemId, versionId) {
27
29
  const client = await this.apiClient();
@@ -105,4 +107,4 @@ export class BaseCommand extends Command {
105
107
  }
106
108
  }
107
109
  //# sourceMappingURL=base-command.js.map
108
- //# debugId=91403767-c5ba-5b5a-8c9b-ca768afefabf
110
+ //# debugId=3c88dddb-c4e4-5734-93dd-f6bf5c033b83
@@ -1 +1 @@
1
- {"version":3,"file":"base-command.js","sources":["../../src/types/base-command.ts"],"sourceRoot":"","sourcesContent":["import { Command } from \"@oclif/core\"\nimport * as Sentry from \"@sentry/node\"\nimport { DTODesignSystem, SupernovaApiClient } from \"@supernova-studio/client\"\nimport inquirer from \"inquirer\"\nimport { z } from \"zod\"\n\nimport { getApiClient } from \"../utils/api-client.js\"\nimport { SupernovaConfigService } from \"../utils/config.service.js\"\nimport { getTargetEnv, TargetEnv } from \"./environment.js\"\n\nconst hasAccess = (role?: DTODesignSystem[\"role\"]) =>\n role && [\"Admin\", \"Contributor\", \"Creator\", \"Owner\"].includes(role)\n\nexport abstract class BaseCommand<T extends object> extends Command {\n protected env: TargetEnv = getTargetEnv()\n protected configService = SupernovaConfigService.getInstance()\n private _apiClient: SupernovaApiClient | undefined\n\n abstract get commandId(): string\n abstract get configSchema(): z.ZodType<T>\n\n protected async apiClient() {\n if (this._apiClient) return this._apiClient\n\n const apiClient = await getApiClient(this.env)\n\n const { user: me } = await apiClient.users.getMe()\n Sentry.setUser({ id: me.id })\n\n return apiClient\n }\n\n protected async init() {\n await super.init()\n this.log(`Using ${this.env} environment`)\n }\n\n protected async promptBrandId(designSystemId: string, versionId?: string): Promise<string> {\n const client = await this.apiClient()\n const brandsEndpoint = client.designSystems.versions.brands\n\n const { brands } = await brandsEndpoint.list(designSystemId, versionId ?? \"head\")\n\n const options = brands.map(b => ({ name: b.meta.name, value: b.persistentId }))\n if (options.length === 1) return options[0].value\n\n return this.prompt(\"Select a brand:\", options)\n }\n\n protected async promptDesignSystemId(): Promise<string> {\n const { designSystems: client } = await this.apiClient()\n const { designSystems, workspaces } = await client.listUserDesignSystems()\n const workspaceById = new Map(workspaces.map(ws => [ws.id, ws]))\n const dsNameCount = designSystems.reduce((acc, { meta: { name }, role }) => {\n if (hasAccess(role)) acc.set(name, (acc.get(name) ?? 0) + 1)\n\n return acc\n }, new Map<string, number>())\n\n if (designSystems.length === 0) {\n this.error(\"You don't have any design system.\")\n }\n\n const dsIds = designSystems\n .sort(({ meta: { name: a } }, { meta: { name: b } }) => a.localeCompare(b))\n .map(({ id, meta: { name }, role, workspaceId }) => ({\n id,\n name: (dsNameCount.get(name) ?? 0) > 1 ? `${name} (${workspaceById.get(workspaceId)?.profile?.name})` : name,\n role,\n }))\n .filter(({ role }) => hasAccess(role))\n\n if (dsIds.length === 0) {\n this.error(\"You don't have access to any design system.\")\n }\n\n if (dsIds.length === 1) {\n return dsIds[0].id\n }\n\n return this.prompt(\n \"Select a design system:\",\n dsIds.map(({ id, name }) => ({\n name,\n value: id,\n })),\n )\n }\n\n protected async getVersionId(designSystemId: string, versionId?: string): Promise<string> {\n if (versionId) return versionId\n const { versions } = (await this.apiClient()).designSystems\n const verIds = (await versions.list(designSystemId)).designSystemVersions.map(({ id, meta: { name } }) => ({\n id,\n name,\n }))\n\n if (verIds.length === 1) {\n return verIds[0].id\n }\n\n return this.prompt(\n \"Select a version:\",\n verIds.map(wrk => ({\n name: wrk.name,\n value: wrk.id,\n })),\n )\n }\n\n protected async getWorkspaceId(workspaceId?: string): Promise<string> {\n if (workspaceId) return workspaceId\n const { workspaces } = await this.apiClient()\n const wrks = (await workspaces.list()).membership.map(\n ({\n workspace: {\n id,\n profile: { name },\n },\n }) => ({ id, name }),\n )\n\n if (wrks.length === 1) {\n return wrks[0].id\n }\n\n return this.prompt(\n \"Select a workspace:\",\n wrks.map(wrk => ({\n name: wrk.name,\n value: wrk.id,\n })),\n )\n }\n\n private async prompt(message: string, choices: { name: string; value: string }[]) {\n const choice = await inquirer.prompt([\n {\n choices: [...choices, { name: \"Exit\", value: \"exit\" }],\n message,\n name: \"selected\",\n type: \"list\",\n },\n ])\n\n return choice.selected as string\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAa,MAAM,kBAAkB,CAAA;AAE1D,MAAM,SAAS,GAAG,CAAC,IAA8B,EAAE,EAAE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AA;IACH,CAAC;IAEO,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,OAA0C;QAC9E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YACnC;gBACE,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;gBACtD,OAAO;gBACP,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,MAAM;aACb;SACF,CAAC,CAAA;QAEF,OAAO,MAAM,CAAC,QAAkB,CAAA;IAClC,CAAC;CACF","debug_id":"91403767-c5ba-5b5a-8c9b-ca768afefabf"}
1
+ {"version":3,"file":"base-command.js","sources":["../../src/types/base-command.ts"],"sourceRoot":"","sourcesContent":["import { Command } from \"@oclif/core\"\nimport * as Sentry from \"@sentry/node\"\nimport { DTODesignSystem, SupernovaApiClient } from \"@supernova-studio/client\"\nimport inquirer from \"inquirer\"\nimport { z } from \"zod\"\n\nimport { getApiClient } from \"../utils/api-client.js\"\nimport { SupernovaConfigService } from \"../utils/config.service.js\"\nimport { getTargetEnv, TargetEnv } from \"./environment.js\"\n\nconst hasAccess = (role?: DTODesignSystem[\"role\"]) =>\n role && [\"Admin\", \"Contributor\", \"Creator\", \"Owner\"].includes(role)\n\nexport abstract class BaseCommand<T extends object> extends Command {\n protected env: TargetEnv = getTargetEnv()\n protected configService = SupernovaConfigService.getInstance()\n private _apiClient: SupernovaApiClient | undefined\n\n abstract get commandId(): string\n abstract get configSchema(): z.ZodType<T>\n\n protected async apiClient() {\n if (this._apiClient) return this._apiClient\n\n const apiClient = await getApiClient(this.env)\n\n const { user: me } = await apiClient.users.getMe()\n Sentry.setUser({ id: me.id })\n\n return apiClient\n }\n\n protected async init() {\n await super.init()\n\n if (this.env !== \"production\") {\n this.log(`Using ${this.env} environment`)\n }\n }\n\n protected async promptBrandId(designSystemId: string, versionId?: string): Promise<string> {\n const client = await this.apiClient()\n const brandsEndpoint = client.designSystems.versions.brands\n\n const { brands } = await brandsEndpoint.list(designSystemId, versionId ?? \"head\")\n\n const options = brands.map(b => ({ name: b.meta.name, value: b.persistentId }))\n if (options.length === 1) return options[0].value\n\n return this.prompt(\"Select a brand:\", options)\n }\n\n protected async promptDesignSystemId(): Promise<string> {\n const { designSystems: client } = await this.apiClient()\n const { designSystems, workspaces } = await client.listUserDesignSystems()\n const workspaceById = new Map(workspaces.map(ws => [ws.id, ws]))\n const dsNameCount = designSystems.reduce((acc, { meta: { name }, role }) => {\n if (hasAccess(role)) acc.set(name, (acc.get(name) ?? 0) + 1)\n\n return acc\n }, new Map<string, number>())\n\n if (designSystems.length === 0) {\n this.error(\"You don't have any design system.\")\n }\n\n const dsIds = designSystems\n .sort(({ meta: { name: a } }, { meta: { name: b } }) => a.localeCompare(b))\n .map(({ id, meta: { name }, role, workspaceId }) => ({\n id,\n name: (dsNameCount.get(name) ?? 0) > 1 ? `${name} (${workspaceById.get(workspaceId)?.profile?.name})` : name,\n role,\n }))\n .filter(({ role }) => hasAccess(role))\n\n if (dsIds.length === 0) {\n this.error(\"You don't have access to any design system.\")\n }\n\n if (dsIds.length === 1) {\n return dsIds[0].id\n }\n\n return this.prompt(\n \"Select a design system:\",\n dsIds.map(({ id, name }) => ({\n name,\n value: id,\n })),\n )\n }\n\n protected async getVersionId(designSystemId: string, versionId?: string): Promise<string> {\n if (versionId) return versionId\n const { versions } = (await this.apiClient()).designSystems\n const verIds = (await versions.list(designSystemId)).designSystemVersions.map(({ id, meta: { name } }) => ({\n id,\n name,\n }))\n\n if (verIds.length === 1) {\n return verIds[0].id\n }\n\n return this.prompt(\n \"Select a version:\",\n verIds.map(wrk => ({\n name: wrk.name,\n value: wrk.id,\n })),\n )\n }\n\n protected async getWorkspaceId(workspaceId?: string): Promise<string> {\n if (workspaceId) return workspaceId\n const { workspaces } = await this.apiClient()\n const wrks = (await workspaces.list()).membership.map(\n ({\n workspace: {\n id,\n profile: { name },\n },\n }) => ({ id, name }),\n )\n\n if (wrks.length === 1) {\n return wrks[0].id\n }\n\n return this.prompt(\n \"Select a workspace:\",\n wrks.map(wrk => ({\n name: wrk.name,\n value: wrk.id,\n })),\n )\n }\n\n private async prompt(message: string, choices: { name: string; value: string }[]) {\n const choice = await inquirer.prompt([\n {\n choices: [...choices, { name: \"Exit\", value: \"exit\" }],\n message,\n name: \"selected\",\n type: \"list\",\n },\n ])\n\n return choice.selected as string\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAa,MAAM,kBAAkB,CAAA;AAE1D,MAAM,SAAS,GAAG,CAAC,IAA8B,EAAE,EAAE,CACnD,IAAI,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAErE,MAAM,OAAgB,WAA8B,SAAQ,OAAO;IACvD,GAAG,GAAc,YAAY,EAAE,CAAA;IAC/B,aAAa,GAAG,sBAAsB,CAAC,WAAW,EAAE,CAAA;IACtD,UAAU,CAAgC;IAKxC,KAAK,CAAC,SAAS;QACvB,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC,UAAU,CAAA;QAE3C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAE9C,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClD,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;QAE7B,OAAO,SA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jD,IAAI,WAAW;YAAE,OAAO,WAAW,CAAA;QACnC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;QAC7C,MAAM,IAAI,GAAG,CAAC,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CACnD,CAAC,EACC,SAAS,EAAE,EACT,EAAE,EACF,OAAO,EAAE,EAAE,IAAI,EAAE,GAClB,GACF,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CACrB,CAAA;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QACnB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAChB,qBAAqB,EACrB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,EAAE;SACd,CAAC,CAAC,CACJ,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,OAA0C;QAC9E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YACnC;gBACE,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;gBACtD,OAAO;gBACP,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,MAAM;aACb;SACF,CAAC,CAAA;QAEF,OAAO,MAAM,CAAC,QAAkB,CAAA;IAClC,CAAC;CACF","debug_id":"3c88dddb-c4e4-5734-93dd-f6bf5c033b83"}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-command.d.ts","sourceRoot":"","sources":["../../src/types/sentry-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;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C,KAAK,EAAE,YAAY,GAAG;QAAE,KAAK,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;IA0BxD,OAAO;IAEA,KAAK,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,SAAS,EAChF,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACxB,IAAI,CAAC,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAgClC"}
@@ -1,15 +1,18 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="558e3980-9ff6-5e3a-bf5c-8e9ad8f4d5b0")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5fd0eafb-6347-5ea5-9e64-049c2e4820a4")}catch(e){}}();
3
3
  import * as Sentry from "@sentry/node";
4
4
  import { isAxiosError } from "axios";
5
5
  import { BaseCommand } from "./base-command.js";
6
6
  import { NotAuthorizedError } from "./not-authorized.error.js";
7
+ import { CLIError } from "@oclif/core/errors";
7
8
  export class SentryCommand extends BaseCommand {
8
9
  constructor(argv, config) {
9
10
  super(argv, config);
10
11
  }
11
12
  async catch(error) {
12
- this.logToStderr(error.message);
13
+ if (!(error instanceof CLIError)) {
14
+ this.logToStderr(error.message);
15
+ }
13
16
  if (error.oclif)
14
17
  throw error;
15
18
  if (error instanceof NotAuthorizedError)
@@ -60,4 +63,4 @@ export class SentryCommand extends BaseCommand {
60
63
  }
61
64
  }
62
65
  //# sourceMappingURL=sentry-command.js.map
63
- //# debugId=558e3980-9ff6-5e3a-bf5c-8e9ad8f4d5b0
66
+ //# debugId=5fd0eafb-6347-5ea5-9e64-049c2e4820a4
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-command.js","sources":["../../src/types/sentry-command.ts"],"sourceRoot":"","sourcesContent":["import { Config } from \"@oclif/core/config\"\nimport { CommandError, Input, ParserOutput } from \"@oclif/core/interfaces\"\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport { ArgOutput, FlagOutput } from \"@oclif/core/lib/interfaces/parser.js\"\nimport * as Sentry from \"@sentry/node\"\nimport { isAxiosError } from \"axios\"\n\nimport { BaseCommand } from \"./base-command.js\"\nimport { NotAuthorizedError } from \"./not-authorized.error.js\"\n\nexport abstract class SentryCommand<T extends object> extends BaseCommand<T> {\n protected constructor(argv: string[], config: Config) {\n super(argv, config)\n }\n\n async catch(error: CommandError & { oclif?: { exit: number } }) {\n this.logToStderr(error.message)\n if (error.oclif) throw error\n if (error instanceof NotAuthorizedError) throw error\n\n if (isAxiosError(error)) {\n const captureMetadata = {\n code: error.code,\n message: error.message,\n response: {\n status: error.response?.status,\n data: error.response?.data,\n },\n }\n\n Sentry.captureMessage(`Axios error metadata: ${JSON.stringify(captureMetadata)}`)\n }\n\n Sentry.captureException(error)\n this.logToStderr(`Something went wrong. Please try again later.`)\n }\n\n async finally() {}\n\n public async parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(\n options?: Input<F, B, A>,\n argv?: string[],\n ): Promise<ParserOutput<F, B, A>> {\n Sentry.addBreadcrumb({\n category: \"command\",\n data: {\n commandName: this.id,\n },\n level: \"debug\",\n message: \"Starting command parse\",\n })\n\n const parsed = await super.parse(options, argv)\n const span = Sentry.getActiveSpan()\n if (span) {\n span.setAttributes({\n args: Object.keys(parsed.args),\n designSystemId: parsed.flags.designSystemId,\n flags: Object.keys(parsed.flags),\n workspaceId: parsed.flags.workspaceId,\n })\n }\n\n Sentry.addBreadcrumb({\n category: \"command\",\n data: {\n result: \"success\",\n },\n level: \"debug\",\n message: \"Command parse completed\",\n })\n\n return parsed\n }\n}\n"],"names":[],"mappings":";;AAKA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,MAAM,OAAgB,aAAgC,SAAQ,WAAc;IAC1E,YAAsB,IAAc,EAAE,MAAc;QAClD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAkD;QAC5D,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC/B,IAAI,KAAK,CAAC,KAAK;YAAE,MAAM,KAAK,CAAA;QAC5B,IAAI,KAAK,YAAY,kBAAkB;YAAE,MAAM,KAAK,CAAA;QAEpD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,eAAe,GAAG;gBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,QAAQ,EAAE;oBACR,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM;oBAC9B,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI;iBAC3B;aACF,CAAA;YAED,MAAM,CAAC,cAAc,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,CAAA;QACnF,CAAC;QAED,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAA;IACnE,CAAC;IAED,KAAK,CAAC,OAAO,KAAI,CAAC;IAEX,KAAK,CAAC,KAAK,CAChB,OAAwB,EACxB,IAAe;QAEf,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE;gBACJ,WAAW,EAAE,IAAI,CAAC,EAAE;aACrB;YACD,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,wBAAwB;SAClC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,EAAE,CAAA;QACnC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,aAAa,CAAC;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC9B,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,cAAc;gBAC3C,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAChC,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW;aACtC,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE;gBACJ,MAAM,EAAE,SAAS;aAClB;YACD,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,yBAAyB;SACnC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;CACF","debug_id":"558e3980-9ff6-5e3a-bf5c-8e9ad8f4d5b0"}
1
+ {"version":3,"file":"sentry-command.js","sources":["../../src/types/sentry-command.ts"],"sourceRoot":"","sourcesContent":["import { Config } from \"@oclif/core/config\"\nimport { CommandError, Input, ParserOutput } from \"@oclif/core/interfaces\"\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport { ArgOutput, FlagOutput } from \"@oclif/core/lib/interfaces/parser.js\"\nimport * as Sentry from \"@sentry/node\"\nimport { isAxiosError } from \"axios\"\n\nimport { BaseCommand } from \"./base-command.js\"\nimport { NotAuthorizedError } from \"./not-authorized.error.js\"\nimport { CLIError } from \"@oclif/core/errors\"\n\nexport abstract class SentryCommand<T extends object> extends BaseCommand<T> {\n protected constructor(argv: string[], config: Config) {\n super(argv, config)\n }\n\n async catch(error: CommandError & { oclif?: { exit: number } }) {\n if (!(error instanceof CLIError)) {\n // Invocations of `this.error(...)` from command classes will already be logged, no need to repeat\n this.logToStderr(error.message)\n }\n\n if (error.oclif) throw error\n if (error instanceof NotAuthorizedError) throw error\n\n if (isAxiosError(error)) {\n const captureMetadata = {\n code: error.code,\n message: error.message,\n response: {\n status: error.response?.status,\n data: error.response?.data,\n },\n }\n\n Sentry.captureMessage(`Axios error metadata: ${JSON.stringify(captureMetadata)}`)\n }\n\n Sentry.captureException(error)\n this.logToStderr(`Something went wrong. Please try again later.`)\n }\n\n async finally() {}\n\n public async parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(\n options?: Input<F, B, A>,\n argv?: string[],\n ): Promise<ParserOutput<F, B, A>> {\n Sentry.addBreadcrumb({\n category: \"command\",\n data: {\n commandName: this.id,\n },\n level: \"debug\",\n message: \"Starting command parse\",\n })\n\n const parsed = await super.parse(options, argv)\n const span = Sentry.getActiveSpan()\n if (span) {\n span.setAttributes({\n args: Object.keys(parsed.args),\n designSystemId: parsed.flags.designSystemId,\n flags: Object.keys(parsed.flags),\n workspaceId: parsed.flags.workspaceId,\n })\n }\n\n Sentry.addBreadcrumb({\n category: \"command\",\n data: {\n result: \"success\",\n },\n level: \"debug\",\n message: \"Command parse completed\",\n })\n\n return parsed\n }\n}\n"],"names":[],"mappings":";;AAKA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAA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AAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,EAAE,CAAA;QACnC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,aAAa,CAAC;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC9B,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,cAAc;gBAC3C,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAChC,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW;aACtC,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,IAAI,EAAE;gBACJ,MAAM,EAAE,SAAS;aAClB;YACD,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,yBAAyB;SACnC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;CACF","debug_id":"5fd0eafb-6347-5ea5-9e64-049c2e4820a4"}
@@ -501,12 +501,12 @@
501
501
  "sync-tokens.js"
502
502
  ]
503
503
  },
504
- "template-upload-docker": {
504
+ "template-upload": {
505
505
  "aliases": [],
506
506
  "args": {},
507
507
  "description": "Upload custom prototype app sandbox template",
508
508
  "examples": [
509
- "<%= config.bin %> <%= command.id %> TemplateUploadDocker "
509
+ "<%= config.bin %> <%= command.id %> TemplateUpload "
510
510
  ],
511
511
  "flags": {
512
512
  "from": {
@@ -540,39 +540,6 @@
540
540
  "hasDynamicHelp": false,
541
541
  "hidden": true,
542
542
  "hiddenAliases": [],
543
- "id": "template-upload-docker",
544
- "pluginAlias": "@supernovaio/cli",
545
- "pluginName": "@supernovaio/cli",
546
- "pluginType": "core",
547
- "strict": true,
548
- "isESM": true,
549
- "relativePath": [
550
- "dist",
551
- "commands",
552
- "template-upload-docker.js"
553
- ]
554
- },
555
- "template-upload": {
556
- "aliases": [],
557
- "args": {},
558
- "description": "Upload custom prototype app sandbox template",
559
- "examples": [
560
- "<%= config.bin %> <%= command.id %> TemplateUpload "
561
- ],
562
- "flags": {
563
- "workspaceId": {
564
- "char": "w",
565
- "description": "Workspace ID to upload the template to",
566
- "name": "workspaceId",
567
- "required": true,
568
- "hasDynamicHelp": false,
569
- "multiple": false,
570
- "type": "option"
571
- }
572
- },
573
- "hasDynamicHelp": false,
574
- "hidden": true,
575
- "hiddenAliases": [],
576
543
  "id": "template-upload",
577
544
  "pluginAlias": "@supernovaio/cli",
578
545
  "pluginName": "@supernovaio/cli",
@@ -608,5 +575,5 @@
608
575
  ]
609
576
  }
610
577
  },
611
- "version": "2.0.15"
578
+ "version": "2.0.17"
612
579
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@supernovaio/cli",
3
3
  "description": "Supernova.io Command Line Interface",
4
- "version": "2.0.15",
4
+ "version": "2.0.17",
5
5
  "author": "Supernova.io",
6
6
  "bin": {
7
7
  "supernova": "./bin/run"
@@ -1,27 +0,0 @@
1
- import { z, ZodType } from "zod";
2
- import { SentryCommand } from "../types/index.js";
3
- declare const TemplateUploadConfig: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
4
- type TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>;
5
- export default class TemplateUploadDocker extends SentryCommand<TemplateUploadConfig> {
6
- static args: {};
7
- static description: string;
8
- static examples: string[];
9
- static hidden: boolean;
10
- static flags: {
11
- from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- workspaceId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
- designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
- };
15
- get commandId(): string;
16
- get configSchema(): ZodType<TemplateUploadConfig>;
17
- run(): Promise<void>;
18
- private validateDockerDaemon;
19
- private createBuildDir;
20
- private deleteBuildDir;
21
- private prepareBuildFolder;
22
- private buildDockerImage;
23
- private pushDockerImage;
24
- private remoteTemplateBuild;
25
- }
26
- export {};
27
- //# sourceMappingURL=template-upload-docker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-upload-docker.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload-docker.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAQ9D,QAAA,MAAM,oBAAoB,gDAAe,CAAA;AAEzC,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAuBhE,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IACnF,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAAiD;IAC5E,OAAgB,QAAQ,WAAgE;IACxF,OAAgB,MAAM,EAAE,OAAO,CAAO;IACtC,OAAgB,KAAK;;;;MAapB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA2CnB,oBAAoB;IAMlC,OAAO,CAAC,cAAc;YAIR,cAAc;YAId,kBAAkB;YAclB,gBAAgB;YAiBhB,eAAe;YAWf,mBAAmB;CA0BlC"}
@@ -1,188 +0,0 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6eb6eb61-932b-5a32-84c1-8a9f053cd157")}catch(e){}}();
3
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
4
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7
- return c > 3 && r && Object.defineProperty(target, key, r), r;
8
- };
9
- var __metadata = (this && this.__metadata) || function (k, v) {
10
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11
- };
12
- import { Flags } from "@oclif/core";
13
- import { action } from "@oclif/core/ux";
14
- import { SentryTraced } from "@sentry/nestjs";
15
- import { exec as execCallback } from "node:child_process";
16
- import * as fs from "node:fs/promises";
17
- import path from "node:path";
18
- import { promisify } from "node:util";
19
- import { z } from "zod";
20
- import fsx from "fs-extra";
21
- import { commonFlags, SentryCommand } from "../types/index.js";
22
- import { sleep } from "../utils/common.js";
23
- import { tmpdir } from "node:os";
24
- const exec = promisify(execCallback);
25
- const TemplateUploadConfig = z.object({});
26
- async function fileExists(p) {
27
- try {
28
- await fs.access(p);
29
- return true;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
35
- const dockerfile = `
36
- FROM node:22-slim
37
-
38
- RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*
39
-
40
- WORKDIR /home/user
41
-
42
- COPY . .
43
- RUN npm i
44
- RUN node docker-scripts/extract-private-packages.js
45
- `;
46
- export default class TemplateUploadDocker extends SentryCommand {
47
- static args = {};
48
- static description = "Upload custom prototype app sandbox template";
49
- static examples = ["<%= config.bin %> <%= command.id %> TemplateUploadDocker "];
50
- static hidden = true;
51
- static flags = {
52
- ...commonFlags,
53
- from: Flags.string({
54
- char: "f",
55
- description: "Directory to upload template from, defaults to the current directory",
56
- required: false,
57
- }),
58
- workspaceId: Flags.string({ char: "w", description: "Workspace ID to upload the template to", required: true }),
59
- designSystemId: Flags.string({
60
- char: "d",
61
- description: "Design system ID to upload the template to",
62
- required: true,
63
- }),
64
- };
65
- get commandId() {
66
- return TemplateUploadDocker.id;
67
- }
68
- get configSchema() {
69
- return TemplateUploadConfig;
70
- }
71
- async run() {
72
- const apiClient = await this.apiClient();
73
- const { flags } = await this.parse();
74
- let pkg;
75
- try {
76
- pkg = await readPackageJson();
77
- }
78
- catch (error) {
79
- if (error instanceof Error)
80
- this.error(`Failed to read or parse package.json: ${error.message}`);
81
- else
82
- throw error;
83
- }
84
- const buildData = await apiClient.sandboxes.builds.start({
85
- workspaceId: flags.workspaceId,
86
- designSystemId: flags.designSystemId,
87
- name: pkg.name,
88
- version: pkg.version,
89
- });
90
- const url = imageUrl(buildData);
91
- await this.validateDockerDaemon();
92
- const buildDir = await this.createBuildDir();
93
- try {
94
- await this.prepareBuildFolder(buildDir);
95
- await this.buildDockerImage(buildDir, url);
96
- await this.pushDockerImage(buildDir, url);
97
- await this.remoteTemplateBuild(apiClient, buildData.build.id);
98
- this.log(`✅ Template has been successfully uploaded`);
99
- }
100
- finally {
101
- await this.deleteBuildDir(buildDir);
102
- }
103
- }
104
- async validateDockerDaemon() {
105
- await exec("docker info").catch(() => {
106
- this.error(`Docker is not available, please start docker daemon and try again`);
107
- });
108
- }
109
- createBuildDir() {
110
- return fs.mkdtemp(path.join(tmpdir(), "supernova-template-bundle-"));
111
- }
112
- async deleteBuildDir(buildDir) {
113
- await fs.rm(buildDir, { recursive: true, force: true });
114
- }
115
- async prepareBuildFolder(buildDir) {
116
- await fsx.copy(process.cwd(), buildDir, {
117
- filter(src) {
118
- return !src.includes("node_modules/") && !src.includes(".git/") && !src.includes(".out/");
119
- },
120
- });
121
- const cliSrcPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
122
- await fsx.copy(path.join(cliSrcPath, "docker-scripts"), path.join(buildDir, "docker-scripts"));
123
- }
124
- async buildDockerImage(buildDir, imageUrl) {
125
- action.start("🔨 Building docker image");
126
- const process = exec(`docker build --progress=plain -t ${imageUrl} --pull --platform linux/amd64 -f - .`, {
127
- cwd: buildDir,
128
- });
129
- process.child.stdin.write(dockerfile);
130
- process.child.stdin.end();
131
- const result = await process;
132
- action.stop("done");
133
- console.log(result.stdout);
134
- console.log(result.stderr);
135
- }
136
- async pushDockerImage(buildDir, imageUrl) {
137
- action.start("⬆️ Uploading docker image to Supernova");
138
- const result = await exec(`docker push ${imageUrl}`, {
139
- cwd: buildDir,
140
- });
141
- action.stop("done");
142
- console.log(result.stdout);
143
- console.log(result.stderr);
144
- }
145
- async remoteTemplateBuild(client, buildId) {
146
- action.start("📦 Creating template with the image");
147
- await client.sandboxes.builds.finalize(buildId);
148
- const pollIntervalMs = 2000;
149
- const timeoutMs = 5 * 60 * 1000;
150
- const startTime = Date.now();
151
- let build;
152
- do {
153
- await sleep(pollIntervalMs);
154
- build = (await client.sandboxes.builds.get(buildId)).build;
155
- } while (build.state === "Building" && Date.now() - startTime < timeoutMs);
156
- if (build.state !== "Success") {
157
- this.error(`Template creation failed`);
158
- }
159
- action.stop("done");
160
- }
161
- }
162
- __decorate([
163
- SentryTraced(),
164
- __metadata("design:type", Function),
165
- __metadata("design:paramtypes", []),
166
- __metadata("design:returntype", Promise)
167
- ], TemplateUploadDocker.prototype, "run", null);
168
- async function readPackageJson() {
169
- const pkgPath = path.join(process.cwd(), "package.json");
170
- if (!(await fileExists(pkgPath)))
171
- throw new Error(`package.json file was not found in the current directory`);
172
- const raw = await fs.readFile(pkgPath, "utf8");
173
- const pkg = JSON.parse(raw);
174
- if (typeof pkg !== "object" || pkg === null)
175
- throw new Error(`Error parsing package.json: not a json`);
176
- if (typeof pkg.name !== "string")
177
- throw new Error(`Error parsing package.json: 'name' must be defined`);
178
- if (typeof pkg.version !== "string")
179
- throw new Error(`Error parsing package.json: 'version' must be defined`);
180
- if (typeof pkg.dependencies !== "object" || pkg.dependencies === null)
181
- throw new Error(`Error parsing package.json: 'dependencies' must be defined`);
182
- return pkg;
183
- }
184
- function imageUrl(build) {
185
- return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`;
186
- }
187
- //# sourceMappingURL=template-upload-docker.js.map
188
- //# debugId=6eb6eb61-932b-5a32-84c1-8a9f053cd157
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-upload-docker.js","sources":["../../src/commands/template-upload-docker.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { exec as execCallback } from \"node:child_process\"\nimport * as fs from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { promisify } from \"node:util\"\nimport { z, ZodType } from \"zod\"\nimport fsx from \"fs-extra\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nimport { DTOSandboxTemplateBuildCreateResponse, SupernovaApiClient } from \"@supernova-studio/client\"\nimport { sleep } from \"../utils/common.js\"\nimport { tmpdir } from \"node:os\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nasync function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\n\nconst dockerfile = `\nFROM node:22-slim\n\nRUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /home/user\n\nCOPY . .\nRUN npm i\nRUN node docker-scripts/extract-private-packages.js\n`\n\nexport default class TemplateUploadDocker extends SentryCommand<TemplateUploadConfig> {\n static override args = {}\n static override description = \"Upload custom prototype app sandbox template\"\n static override examples = [\"<%= config.bin %> <%= command.id %> TemplateUploadDocker \"]\n static override hidden: boolean = true\n static override flags = {\n ...commonFlags,\n from: Flags.string({\n char: \"f\",\n description: \"Directory to upload template from, defaults to the current directory\",\n required: false,\n }),\n workspaceId: Flags.string({ char: \"w\", description: \"Workspace ID to upload the template to\", required: true }),\n designSystemId: Flags.string({\n char: \"d\",\n description: \"Design system ID to upload the template to\",\n required: true,\n }),\n }\n\n get commandId(): string {\n return TemplateUploadDocker.id\n }\n\n get configSchema(): ZodType<TemplateUploadConfig> {\n return TemplateUploadConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const apiClient = await this.apiClient()\n const { flags } = await this.parse()\n\n // Read package json\n let pkg\n try {\n pkg = await readPackageJson()\n } catch (error) {\n if (error instanceof Error) this.error(`Failed to read or parse package.json: ${error.message}`)\n else throw error\n }\n\n //\n // From here\n //\n\n // Request build\n const buildData = await apiClient.sandboxes.builds.start({\n workspaceId: flags.workspaceId,\n designSystemId: flags.designSystemId,\n name: pkg.name,\n version: pkg.version,\n })\n\n // Build image\n const url = imageUrl(buildData)\n\n await this.validateDockerDaemon()\n const buildDir = await this.createBuildDir()\n\n try {\n await this.prepareBuildFolder(buildDir)\n await this.buildDockerImage(buildDir, url)\n await this.pushDockerImage(buildDir, url)\n await this.remoteTemplateBuild(apiClient, buildData.build.id)\n\n this.log(`✅ Template has been successfully uploaded`)\n } finally {\n await this.deleteBuildDir(buildDir)\n }\n }\n\n private async validateDockerDaemon() {\n await exec(\"docker info\").catch(() => {\n this.error(`Docker is not available, please start docker daemon and try again`)\n })\n }\n\n private createBuildDir(): Promise<string> {\n return fs.mkdtemp(path.join(tmpdir(), \"supernova-template-bundle-\"))\n }\n\n private async deleteBuildDir(buildDir: string) {\n await fs.rm(buildDir, { recursive: true, force: true })\n }\n\n private async prepareBuildFolder(buildDir: string) {\n // Move working directory to temp folder from where it will be built\n await fsx.copy(process.cwd(), buildDir, {\n filter(src) {\n return !src.includes(\"node_modules/\") && !src.includes(\".git/\") && !src.includes(\".out/\")\n },\n })\n\n // Inject Supernova scripts\n const cliSrcPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), \"..\")\n\n await fsx.copy(path.join(cliSrcPath, \"docker-scripts\"), path.join(buildDir, \"docker-scripts\"))\n }\n\n private async buildDockerImage(buildDir: string, imageUrl: string) {\n action.start(\"🔨 Building docker image\")\n\n const process = exec(`docker build --progress=plain -t ${imageUrl} --pull --platform linux/amd64 -f - .`, {\n cwd: buildDir,\n })\n process.child.stdin!.write(dockerfile)\n process.child.stdin!.end()\n\n const result = await process\n\n action.stop(\"done\")\n\n console.log(result.stdout)\n console.log(result.stderr)\n }\n\n private async pushDockerImage(buildDir: string, imageUrl: string) {\n action.start(\"⬆️ Uploading docker image to Supernova\")\n const result = await exec(`docker push ${imageUrl}`, {\n cwd: buildDir,\n })\n action.stop(\"done\")\n\n console.log(result.stdout)\n console.log(result.stderr)\n }\n\n private async remoteTemplateBuild(client: SupernovaApiClient, buildId: string) {\n // Poll every 2 seconds for roughly 5 minutes\n action.start(\"📦 Creating template with the image\")\n\n // Trigger remote build phase\n await client.sandboxes.builds.finalize(buildId)\n\n // Await remote build\n const pollIntervalMs = 2000\n const timeoutMs = 5 * 60 * 1000\n\n const startTime = Date.now()\n\n let build\n do {\n await sleep(pollIntervalMs)\n build = (await client.sandboxes.builds.get(buildId)).build\n } while (build.state === \"Building\" && Date.now() - startTime < timeoutMs)\n\n // Verify build state\n if (build.state !== \"Success\") {\n this.error(`Template creation failed`)\n }\n\n action.stop(\"done\")\n }\n}\n\ntype PackageJson = { name: string; version: string; dependencies: Record<string, string> }\n\nasync function readPackageJson(): Promise<PackageJson> {\n const pkgPath = path.join(process.cwd(), \"package.json\")\n\n if (!(await fileExists(pkgPath))) throw new Error(`package.json file was not found in the current directory`)\n\n const raw = await fs.readFile(pkgPath, \"utf8\")\n const pkg = JSON.parse(raw)\n\n if (typeof pkg !== \"object\" || pkg === null) throw new Error(`Error parsing package.json: not a json`)\n\n if (typeof pkg.name !== \"string\") throw new Error(`Error parsing package.json: 'name' must be defined`)\n if (typeof pkg.version !== \"string\") throw new Error(`Error parsing package.json: 'version' must be defined`)\n if (typeof pkg.dependencies !== \"object\" || pkg.dependencies === null)\n throw new Error(`Error parsing package.json: 'dependencies' must be defined`)\n\n return pkg\n}\n\nfunction imageUrl(build: DTOSandboxTemplateB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