@supernovaio/cli 2.0.13 → 2.0.15

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.
@@ -0,0 +1,27 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,188 @@
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
@@ -0,0 +1 @@
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: DTOSandboxTemplateBuildCreateResponse) {\n return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`\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,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,OA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AM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE3B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;IAEtG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACvG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;IAC7G,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,QAAQ,IAAI,GAAG,CAAC,YAAY,KAAK,IAAI;QACnE,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAA;IAE/E,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,QAAQ,CAAC,KAA4C;IAC5D,OAAO,GAAG,KAAK,CAAC,oBAAoB,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,CAAA;AACtE,CAAC","debug_id":"6eb6eb61-932b-5a32-84c1-8a9f053cd157"}
@@ -0,0 +1,74 @@
1
+ import { execSync } from "node:child_process"
2
+ import fs from "node:fs"
3
+ import path from "node:path"
4
+
5
+ const PRIVATE_DEPS_DIR_NAME = "private-deps"
6
+
7
+ ;(() => {
8
+ const packageJsonPath = path.join(process.cwd(), "package.json")
9
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString())
10
+
11
+ const privateDependencies = packageJson.supernova?.privateDependencies
12
+ if (!privateDependencies) return
13
+ if (!Array.isArray(privateDependencies)) {
14
+ throw new TypeError(
15
+ `supernova.privateDependencies must be an array, example: "privateDependencies": ["@example/package"]`,
16
+ )
17
+ }
18
+
19
+ if (privateDependencies.length === 0) return
20
+
21
+ // Validate all private dependencies
22
+ for (const [i, d] of privateDependencies.entries()) {
23
+ if (typeof d !== "string") {
24
+ throw new TypeError(`Invalid value at supernova.privateDependencies[${i}]: '${d}'`)
25
+ }
26
+
27
+ if (!packageJson.dependencies[d]) {
28
+ throw new Error(`Private dependency ${d} must be present in package.json dependencies`)
29
+ }
30
+
31
+ if (!fs.existsSync(getDependencySourceFullPath(d))) {
32
+ throw new Error(`Private dependency ${d} must be present in node_modules`)
33
+ }
34
+ }
35
+
36
+ for (const dependency of privateDependencies) {
37
+ // Move the dependency
38
+ const src = getDependencySourceFullPath(dependency)
39
+ const target = getDependencyTargetFullPath(dependency)
40
+
41
+ try {
42
+ // Make sure the target directory exists
43
+ fs.mkdirSync(target, { recursive: true })
44
+
45
+ // Copy folder to private-deps
46
+ execSync(`cp -R ${src}/ ${path.dirname(target)}`)
47
+
48
+ // Remove from source
49
+ fs.rmSync(src, { recursive: true })
50
+ } catch (error) {
51
+ console.error(`Couldn't move dependency ${dependency} from ${src} to ${target}`)
52
+ throw error
53
+ }
54
+
55
+ // Switch dependency from version to file directive
56
+ packageJson.dependencies[dependency] = `file:${getDependencyTargetRelativePath(dependency)}`
57
+ }
58
+
59
+ fs.writeFileSync(packageJsonPath, Buffer.from(JSON.stringify(packageJson, null, 2) + "\n"))
60
+ })()
61
+
62
+ function getDependencySourceFullPath(name) {
63
+ return path.join(process.cwd(), "node_modules", name)
64
+ }
65
+
66
+ function getDependencyTargetFullPath(name) {
67
+ return path.join(process.cwd(), PRIVATE_DEPS_DIR_NAME, name)
68
+ }
69
+
70
+ function getDependencyTargetRelativePath(name) {
71
+ return path.join(".", PRIVATE_DEPS_DIR_NAME, name)
72
+ }
73
+ !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]="c8431c5b-b015-5d9d-bdef-9202f73e7f49")}catch(e){}}();
74
+ //# debugId=c8431c5b-b015-5d9d-bdef-9202f73e7f49
@@ -1 +1 @@
1
- {"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD,KAAK;;;;;;;wBAIsg7qV,CAAC;sBAA4C,CAAC;0BAAgD,CAAC;+BAAmC,CAAC;uCAA6D,CAAC;8CAAoE,CAAC;8BAAoD,CAAC;4BAAoG,CAAC;yBAA+C,CAAC;4BAAkD,CAAC;oCAA+G,CAAC;sCAA4D,CAAC;iDAAuE,CAAC;4BAAmD,CAAC;iDAAuE,CAAC;;qBAA2E,CAAC;mCAAuC,CAAC;+BAAqD,CAAC;4BAAkD,CAAC;sCAA4D,CAAC;4CAAmE,CAAC;qCAA2D,CAAC;iCAAuD,CAAC;0BAAiD,CAAC;;2BAA8M,CAAC;mCAAuC,CAAC;+BAAqD,CAAC;4BAAkD,CAAC;sCAA4D,CAAC;4CAAmE,CAAC;qCAA2D,CAAC;iCAAuD,CAAC;0BAAiD,CAAC;;;;;;uBAAiU,CAAC;kBAAsC,CAAC;;;CADp3/qV"}
1
+ {"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD,KAAK;;;;;;;wBAIwr++d,CAAC;sBAA4C,CAAC;0BAAgD,CAAC;+BAAmC,CAAC;uCAA6D,CAAC;8CAAoE,CAAC;8BAAoD,CAAC;4BAAoG,CAAC;yBAA+C,CAAC;4BAAkD,CAAC;oCAA+G,CAAC;sCAA4D,CAAC;iDAAuE,CAAC;4BAAmD,CAAC;iDAAuE,CAAC;;qBAA2E,CAAC;mCAAuC,CAAC;+BAAqD,CAAC;4BAAkD,CAAC;sCAA4D,CAAC;4CAAmE,CAAC;qCAA2D,CAAC;iCAAuD,CAAC;0BAAiD,CAAC;;2BAA8M,CAAC;mCAAuC,CAAC;+BAAqD,CAAC;4BAAkD,CAAC;sCAA4D,CAAC;4CAAmE,CAAC;qCAA2D,CAAC;iCAAuD,CAAC;0BAAiD,CAAC;;;;;;uBAAiU,CAAC;kBAAsC,CAAC;;;CADtij/d"}
@@ -501,6 +501,57 @@
501
501
  "sync-tokens.js"
502
502
  ]
503
503
  },
504
+ "template-upload-docker": {
505
+ "aliases": [],
506
+ "args": {},
507
+ "description": "Upload custom prototype app sandbox template",
508
+ "examples": [
509
+ "<%= config.bin %> <%= command.id %> TemplateUploadDocker "
510
+ ],
511
+ "flags": {
512
+ "from": {
513
+ "char": "f",
514
+ "description": "Directory to upload template from, defaults to the current directory",
515
+ "name": "from",
516
+ "required": false,
517
+ "hasDynamicHelp": false,
518
+ "multiple": false,
519
+ "type": "option"
520
+ },
521
+ "workspaceId": {
522
+ "char": "w",
523
+ "description": "Workspace ID to upload the template to",
524
+ "name": "workspaceId",
525
+ "required": true,
526
+ "hasDynamicHelp": false,
527
+ "multiple": false,
528
+ "type": "option"
529
+ },
530
+ "designSystemId": {
531
+ "char": "d",
532
+ "description": "Design system ID to upload the template to",
533
+ "name": "designSystemId",
534
+ "required": true,
535
+ "hasDynamicHelp": false,
536
+ "multiple": false,
537
+ "type": "option"
538
+ }
539
+ },
540
+ "hasDynamicHelp": false,
541
+ "hidden": true,
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
+ },
504
555
  "template-upload": {
505
556
  "aliases": [],
506
557
  "args": {},
@@ -557,5 +608,5 @@
557
608
  ]
558
609
  }
559
610
  },
560
- "version": "2.0.13"
611
+ "version": "2.0.15"
561
612
  }
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.13",
4
+ "version": "2.0.15",
5
5
  "author": "Supernova.io",
6
6
  "bin": {
7
7
  "supernova": "./bin/run"
@@ -16,16 +16,18 @@
16
16
  "@sentry/node": "^9.9.0",
17
17
  "@sentry/profiling-node": "^9.9.0",
18
18
  "@sindresorhus/slugify": "^2.2.1",
19
- "@supernova-studio/client": "1.48.8",
19
+ "@supernova-studio/client": "1.50.6",
20
20
  "@supernova-studio/pulsar-core": "2.6.13",
21
21
  "@supernova-studio/pulsar-language": "^2.6.12",
22
22
  "@supernovaio/code-analyzer": "^1.0.1-alpha.2",
23
23
  "@supernovaio/sdk": "2.0.36",
24
+ "@types/fs-extra": "^11.0.4",
24
25
  "adm-zip": "^0.5.16",
25
26
  "axios": "^1.8.4",
26
27
  "cli-progress": "^3.12.0",
27
28
  "colors": "^1.4.0",
28
29
  "dotenv": "^16.4.7",
30
+ "fs-extra": "^11.3.2",
29
31
  "inquirer": "^12.5.2",
30
32
  "ip-cidr": "^4.0.2",
31
33
  "jwt-decode": "^4.0.0",
@@ -130,7 +132,7 @@
130
132
  },
131
133
  "repository": "https://github.com/Supernova-Studio/cli",
132
134
  "scripts": {
133
- "build": "npx shx rm -rf dist && tsc -b",
135
+ "build": "npx shx rm -rf dist && tsc -b && cp -R ./src/docker-scripts ./dist",
134
136
  "check-types": "tsc --noEmit",
135
137
  "lint": "eslint",
136
138
  "lint:ci": "eslint . --quiet",