@frontify/frontify-cli 5.10.2 → 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,966 +1,946 @@
1
1
  #!/usr/bin/env node
2
- import ue, { join as m, resolve as O } from "node:path";
3
- import { exit as W } from "node:process";
4
- import { cac as he } from "cac";
5
- import j from "prompts";
6
- import E from "fast-glob";
7
- import Q from "open";
8
- import b from "picocolors";
9
- import { readFileSync as N, writeFileSync as X, readdirSync as ee, mkdirSync as ye, statSync as ge, copyFileSync as we } from "node:fs";
10
- import ve from "conf";
11
- import be from "glob-to-regexp";
2
+ import e, { join as t, resolve as n } from "node:path";
3
+ import { exit as r } from "node:process";
4
+ import { cac as i } from "cac";
5
+ import a from "prompts";
6
+ import o from "fast-glob";
7
+ import s from "open";
8
+ import c from "picocolors";
9
+ import { copyFileSync as l, mkdirSync as u, readFileSync as d, readdirSync as f, statSync as p, writeFileSync as m } from "node:fs";
10
+ import h from "conf";
11
+ import ee from "glob-to-regexp";
12
12
  import "node:crypto";
13
- import xe from "node-fetch";
14
- import { exec as Ee } from "node:child_process";
15
- import { URL as ke, fileURLToPath as $e } from "node:url";
13
+ import g from "node-fetch";
14
+ import { exec as _ } from "node:child_process";
15
+ import { URL as te, fileURLToPath as ne } from "node:url";
16
16
  import "archiver";
17
- import x from "@vitejs/plugin-react";
18
- import { build as A, createServer as B } from "vite";
19
- import { viteExternalsPlugin as C } from "vite-plugin-externals";
20
- import { object as c, string as a, z as w, array as l, number as te, boolean as Se } from "zod";
21
- import Te from "@fastify/cors";
22
- import Pe from "fastify";
23
- import * as Ce from "esbuild";
24
- const De = "@frontify/frontify-cli", Oe = "module", Ae = "5.10.2", Fe = "Frontify Developers <developers@frontify.com>", Ue = { type: "git", url: "https://github.com/Frontify/brand-sdk", directory: "packages/cli" }, Re = { "frontify-cli": "dist/index.mjs" }, _e = ["dist", "templates"], Ie = { node: ">=18" }, je = { build: "vite build", dev: "vite build --watch", format: "prettier --write .", lint: "eslint .", "lint:fix": "eslint --fix .", start: "npm run build && node dist/index.mjs", test: "vitest run --silent", "test:watch": "vitest", "test:coverage": "vitest run --coverage", "test:ui": "vitest --ui", typecheck: "tsc --noEmit" }, Ne = { "@fastify/cors": "^11.2.0", "@vitejs/plugin-react": "^5.2.0", archiver: "^7.0.1", cac: "^6.7.14", conf: "^15.1.0", esbuild: "^0.27.4", "fast-glob": "^3.3.3", fastify: "^5.8.2", "glob-to-regexp": "^0.4.1", "node-fetch": "^3.3.2", open: "^11.0.0", picocolors: "^1.1.1", prompts: "^2.4.2", vite: "^7.3.1", "vite-plugin-externals": "^0.6.2", zod: "^3.25.76" }, Be = { "@frontify/eslint-config-basic": "^1.0.8", "@types/glob-to-regexp": "^0.4.4", "@types/mock-fs": "^4.13.4", "@types/node": "^20.19.25", "@types/prompts": "^2.4.9", "@types/ws": "8.18.1", "@vitest/coverage-v8": "4.1.0", "@vitest/ui": "^4.1.0", eslint: "^9.39.4", "eslint-plugin-notice": "^1.0.0", nock: "^13.5.6", prettier: "^3.7.4", "ts-node": "^10.9.2", typescript: "^5.9.3", vitest: "^4.1.0" }, F = {
25
- name: De,
26
- type: Oe,
27
- version: Ae,
28
- author: Fe,
29
- repository: Ue,
30
- bin: Re,
31
- files: _e,
32
- engines: Ie,
33
- scripts: je,
34
- dependencies: Ne,
35
- devDependencies: Be
36
- }, I = () => {
37
- const e = /* @__PURE__ */ new Date();
38
- return `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}:${String(
39
- e.getSeconds()
40
- ).padStart(2, "0")}`;
41
- };
42
- class s {
43
- static defaultInfo(...t) {
44
- console.log(s.spacer(10), ...t);
45
- }
46
- static info(...t) {
47
- console.log(`[${I()}] ${t.join(" ")}`);
48
- }
49
- static success(...t) {
50
- console.log(`[${I()}] ${b.green(t.join(" "))}`);
51
- }
52
- static error(...t) {
53
- console.error(b.red(`[${I()}] ${t.join(" ")}`));
54
- }
55
- static spacer(t = 1) {
56
- return Array(t + 1).join(" ");
57
- }
58
- }
59
- class U extends Error {
60
- constructor(t) {
61
- super(), this.name = "FileNotFoundError", s.error(`The file at "${t}" was not found.`);
62
- }
63
- }
64
- class Le extends Error {
65
- constructor(t) {
66
- super(), this.name = "ParseJsonError", s.error(`The file at "${t}" could not be parsed.`);
67
- }
68
- }
69
- const $ = (e) => {
70
- try {
71
- const t = N(e, "utf8"), n = JSON.parse(t);
72
- return new Proxy(n, {
73
- set: (r, o, i) => {
74
- r[o] = i;
75
- const p = JSON.stringify(r, null, " ");
76
- return X(e, p), !0;
77
- }
78
- });
79
- } catch (t) {
80
- throw t instanceof SyntaxError ? new Le(e) : t.code === "ENOENT" ? new U(e) : new Error(t);
81
- }
82
- }, L = (e) => $(m(e, "package.json")).dependencies["@frontify/app-bridge"];
83
- class k {
84
- static {
85
- this.conf = new ve({
86
- projectName: "frontify-cli"
87
- });
88
- }
89
- static set(t, n) {
90
- this.conf.set(t, n);
91
- }
92
- static get(t) {
93
- return this.conf.get(t, void 0);
94
- }
95
- static delete(t) {
96
- return this.conf.delete(t);
97
- }
98
- }
99
- const Ve = (e) => {
100
- try {
101
- return ee(e).length === 0;
102
- } catch {
103
- return !0;
104
- }
105
- }, ne = (e, t, n) => {
106
- ye(t, { recursive: !0 });
107
- const r = n?.exclude.map((o) => be(o));
108
- for (const o of ee(e)) {
109
- if (r !== void 0 && r.some((u) => u.test(o)))
110
- continue;
111
- const i = O(e, o), p = O(t, o);
112
- Je(i, p);
113
- }
114
- }, Je = (e, t) => {
115
- ge(e).isDirectory() ? ne(e, t) : we(e, t);
116
- }, Me = (e) => {
117
- try {
118
- return N(e, "utf-8");
119
- } catch {
120
- throw new U(e);
121
- }
122
- }, ze = (e) => {
123
- try {
124
- return N(e, "base64");
125
- } catch {
126
- throw new U(e);
127
- }
128
- }, He = (e) => {
129
- try {
130
- return Me(e).split(/\r?\n/).filter((n) => n !== "");
131
- } catch {
132
- throw new U(e);
133
- }
134
- };
135
- class Ye extends Error {
136
- constructor(t, n) {
137
- super(`Status code ${t}`), this.code = 0, this.name = "HttpClientError", this.code = t, this.responseBody = n;
138
- }
139
- }
140
- class V {
141
- constructor(t) {
142
- this.baseUrl = t.replace(/^https?:\/\//, "");
143
- }
144
- async fetchExtended({ method: t, url: n, body: r, options: o }) {
145
- const i = await xe(this.getAbsoluteUrl(n), {
146
- method: t,
147
- ...r && {
148
- body: JSON.stringify(r)
149
- },
150
- ...o,
151
- headers: { "Content-Type": "application/json", ...o?.headers }
152
- });
153
- if (i.status === 200)
154
- if (i.headers.get("Content-Type") === "application/json") {
155
- const u = await i.json();
156
- return u || void 0;
157
- } else {
158
- const u = await i.text();
159
- return u || void 0;
160
- }
161
- else {
162
- const p = await i.json();
163
- throw new Ye(i.status, p);
164
- }
165
- }
166
- get(t, n) {
167
- return this.fetchExtended({ url: t, method: "GET", options: n });
168
- }
169
- post(t, n, r) {
170
- return this.fetchExtended({ url: t, method: "POST", body: n, options: r });
171
- }
172
- put(t, n, r) {
173
- return this.fetchExtended({ url: t, method: "PUT", body: n, options: r });
174
- }
175
- delete(t, n) {
176
- return this.fetchExtended({ url: t, method: "DELETE", options: n });
177
- }
178
- getAbsoluteUrl(t) {
179
- return `https://${this.baseUrl}${t}`;
180
- }
181
- }
182
- const qe = (e) => {
183
- const t = O(e, "package.json"), n = $(t);
184
- n.name = e;
185
- }, Ze = (e) => e ? /^[_a-z-]+$/.test(e) ? Ve(e) ? !0 : `The directory ./${e} already exist.` : 'The project name needs to be "a-z" separated by "-" or "_".' : "The content block name can not be empty.";
186
- class Ke extends Error {
187
- constructor(t) {
188
- super(), this.name = "CommandExecutionError", s.error(`The command execution failed: ${t}`);
189
- }
190
- }
191
- const M = (e, t = {}) => new Promise((n, r) => {
192
- Ee(e, t, (o, i) => o ? r(new Ke(o + i)) : n(i));
193
- });
194
- class Ge extends Error {
195
- constructor(t) {
196
- super(), this.name = "InvalidInstanceUrlError", t ? s.error(`The given URL "${t}" is invalid.`) : s.error("No instance URL was given.");
197
- }
198
- }
199
- const re = (e) => {
200
- try {
201
- const t = e.replace(/^https?:\/\//, "");
202
- return new ke(`https://${t}`).hostname;
203
- } catch {
204
- throw new Ge(e);
205
- }
206
- }, oe = async (e, t) => {
207
- const n = new V(e), r = t || k.get("tokens.access_token");
208
- try {
209
- return (await n.post(
210
- "/graphql",
211
- { query: "{ currentUser { email name } }" },
212
- { headers: { Authorization: `Bearer ${r}` } }
213
- )).data.currentUser;
214
- } catch {
215
- s.error(
216
- `You are currently not logged in. You can use the command ${b.bold("frontify-cli login")} to log in.`
217
- );
218
- return;
219
- }
220
- }, We = (e, t) => {
221
- const n = m(e, ".gitignore");
222
- X(n, Qe[t]);
223
- }, Qe = {
224
- "platform-app": `# Logs
225
- logs
226
- *.log
227
- npm-debug.log*
228
- yarn-debug.log*
229
- yarn-error.log*
230
- pnpm-debug.log*
231
- lerna-debug.log*
232
-
233
- node_modules
234
- dist
235
- dist-ssr
236
- *.localdist
237
- .idea
238
- .vscode
239
-
240
- # Editor directories and files
241
- .DS_Store
242
- *.suo
243
- *.ntvs*
244
- *.njsproj
245
- *.sln
246
- *.sw?
247
- .secret.json
248
- `,
249
- "content-block": `node_modules
250
- dist
251
- .idea
252
- .vscode
253
- `
254
- }, Xe = async ({ outputName: e, entryFile: t, projectPath: n = "" }) => {
255
- const r = L(n), o = await A({
256
- plugins: [
257
- x(),
258
- C({
259
- react: "React",
260
- "react-dom": "ReactDOM"
261
- })
262
- ],
263
- root: n,
264
- define: {
265
- "process.env.NODE_ENV": JSON.stringify("production")
266
- },
267
- build: {
268
- lib: {
269
- entry: t,
270
- name: e,
271
- formats: ["iife"],
272
- fileName: () => "index.js"
273
- },
274
- rollupOptions: {
275
- external: ["react", "react-dom"],
276
- output: {
277
- globals: {
278
- react: "React",
279
- "react-dom": "ReactDOM"
280
- },
281
- entryFileNames: "settings.js",
282
- footer: `
17
+ import v from "@vitejs/plugin-react";
18
+ import { build as y, createServer as b, esmExternalRequirePlugin as x } from "vite";
19
+ import { viteExternalsPlugin as re } from "vite-plugin-externals";
20
+ import { array as S, boolean as ie, number as ae, object as C, string as w, z as T } from "zod";
21
+ import oe from "@fastify/cors";
22
+ import se from "fastify";
23
+ import * as ce from "esbuild";
24
+ var E = {
25
+ name: "@frontify/frontify-cli",
26
+ type: "module",
27
+ version: "6.0.0-alpha.0",
28
+ author: "Frontify Developers <developers@frontify.com>",
29
+ repository: {
30
+ type: "git",
31
+ url: "https://github.com/Frontify/brand-sdk",
32
+ directory: "packages/cli"
33
+ },
34
+ bin: { "frontify-cli": "dist/index.mjs" },
35
+ files: ["dist", "templates"],
36
+ engines: { node: ">=22" },
37
+ scripts: {
38
+ build: "vite build",
39
+ dev: "vite build --watch",
40
+ format: "prettier --write .",
41
+ lint: "eslint .",
42
+ "lint:fix": "eslint --fix .",
43
+ start: "npm run build && node dist/index.mjs",
44
+ test: "vitest run --silent",
45
+ "test:watch": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "test:ui": "vitest --ui",
48
+ typecheck: "tsc --noEmit"
49
+ },
50
+ dependencies: {
51
+ "@fastify/cors": "^11.2.0",
52
+ "@vitejs/plugin-react": "^6.0.1",
53
+ archiver: "^7.0.1",
54
+ cac: "^7.0.0",
55
+ conf: "^15.1.0",
56
+ esbuild: "^0.27.4",
57
+ "fast-glob": "^3.3.3",
58
+ fastify: "^5.8.2",
59
+ "glob-to-regexp": "^0.4.1",
60
+ "node-fetch": "^3.3.2",
61
+ open: "^11.0.0",
62
+ picocolors: "^1.1.1",
63
+ prompts: "^2.4.2",
64
+ vite: "^8.0.0",
65
+ "vite-plugin-externals": "^0.6.2",
66
+ zod: "^3.25.76"
67
+ },
68
+ devDependencies: {
69
+ "@frontify/eslint-config-basic": "^1.0.8",
70
+ "@types/glob-to-regexp": "^0.4.4",
71
+ "@types/mock-fs": "^4.13.4",
72
+ "@types/node": "^22.19.15",
73
+ "@types/prompts": "^2.4.9",
74
+ "@types/ws": "8.18.1",
75
+ "@vitest/coverage-v8": "4.1.0",
76
+ "@vitest/ui": "^4.1.0",
77
+ eslint: "^9.39.4",
78
+ "eslint-plugin-notice": "^1.0.0",
79
+ nock: "^13.5.6",
80
+ prettier: "^3.7.4",
81
+ "ts-node": "^10.9.2",
82
+ typescript: "^5.9.3",
83
+ vitest: "^4.1.0"
84
+ }
85
+ }, D = () => {
86
+ let e = /* @__PURE__ */ new Date();
87
+ return `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}:${String(e.getSeconds()).padStart(2, "0")}`;
88
+ }, O = class e {
89
+ static defaultInfo(...t) {
90
+ console.log(e.spacer(10), ...t);
91
+ }
92
+ static info(...e) {
93
+ console.log(`[${D()}] ${e.join(" ")}`);
94
+ }
95
+ static success(...e) {
96
+ console.log(`[${D()}] ${c.green(e.join(" "))}`);
97
+ }
98
+ static error(...e) {
99
+ console.error(c.red(`[${D()}] ${e.join(" ")}`));
100
+ }
101
+ static spacer(e = 1) {
102
+ return Array(e + 1).join(" ");
103
+ }
104
+ }, k = class extends Error {
105
+ name = "FileNotFoundError";
106
+ constructor(e) {
107
+ super(), O.error(`The file at "${e}" was not found.`);
108
+ }
109
+ }, le = class extends Error {
110
+ name = "ParseJsonError";
111
+ constructor(e) {
112
+ super(), O.error(`The file at "${e}" could not be parsed.`);
113
+ }
114
+ }, A = (e) => {
115
+ try {
116
+ let t = d(e, "utf8"), n = JSON.parse(t);
117
+ return new Proxy(n, { set: (t, n, r) => (t[n] = r, m(e, JSON.stringify(t, null, " ")), !0) });
118
+ } catch (t) {
119
+ throw t instanceof SyntaxError ? new le(e) : t.code === "ENOENT" ? new k(e) : Error(t);
120
+ }
121
+ }, j = (e) => A(t(e, "package.json")).dependencies["@frontify/app-bridge"], ue = (e) => A(t(e, "package.json")).dependencies["@frontify/app-bridge-theme"], M = (e) => A(t(e, "package.json")).dependencies.react, N = class {
122
+ static conf = new h({ projectName: "frontify-cli" });
123
+ static set(e, t) {
124
+ this.conf.set(e, t);
125
+ }
126
+ static get(e) {
127
+ return this.conf.get(e, void 0);
128
+ }
129
+ static delete(e) {
130
+ return this.conf.delete(e);
131
+ }
132
+ }, de = (e) => {
133
+ try {
134
+ return f(e).length === 0;
135
+ } catch {
136
+ return !0;
137
+ }
138
+ }, P = (e, t, r) => {
139
+ u(t, { recursive: !0 });
140
+ let i = r?.exclude.map((e) => ee(e));
141
+ for (let r of f(e)) i !== void 0 && i.some((e) => e.test(r)) || fe(n(e, r), n(t, r));
142
+ }, fe = (e, t) => {
143
+ p(e).isDirectory() ? P(e, t) : l(e, t);
144
+ }, pe = (e) => {
145
+ try {
146
+ return d(e, "utf-8");
147
+ } catch {
148
+ throw new k(e);
149
+ }
150
+ }, me = (e) => {
151
+ try {
152
+ return d(e, "base64");
153
+ } catch {
154
+ throw new k(e);
155
+ }
156
+ }, he = (e) => {
157
+ try {
158
+ return pe(e).split(/\r?\n/).filter((e) => e !== "");
159
+ } catch {
160
+ throw new k(e);
161
+ }
162
+ }, ge = class extends Error {
163
+ code = 0;
164
+ responseBody;
165
+ constructor(e, t) {
166
+ super(`Status code ${e}`), this.name = "HttpClientError", this.code = e, this.responseBody = t;
167
+ }
168
+ }, F = class {
169
+ baseUrl;
170
+ constructor(e) {
171
+ this.baseUrl = e.replace(/^https?:\/\//, "");
172
+ }
173
+ async fetchExtended({ method: e, url: t, body: n, options: r }) {
174
+ let i = await g(this.getAbsoluteUrl(t), {
175
+ method: e,
176
+ ...n && { body: JSON.stringify(n) },
177
+ ...r,
178
+ headers: {
179
+ "Content-Type": "application/json",
180
+ ...r?.headers
181
+ }
182
+ });
183
+ if (i.status === 200) switch (i.headers.get("Content-Type")) {
184
+ case "application/json": return await i.json() || void 0;
185
+ default: return await i.text() || void 0;
186
+ }
187
+ else {
188
+ let e = await i.json();
189
+ throw new ge(i.status, e);
190
+ }
191
+ }
192
+ get(e, t) {
193
+ return this.fetchExtended({
194
+ url: e,
195
+ method: "GET",
196
+ options: t
197
+ });
198
+ }
199
+ post(e, t, n) {
200
+ return this.fetchExtended({
201
+ url: e,
202
+ method: "POST",
203
+ body: t,
204
+ options: n
205
+ });
206
+ }
207
+ put(e, t, n) {
208
+ return this.fetchExtended({
209
+ url: e,
210
+ method: "PUT",
211
+ body: t,
212
+ options: n
213
+ });
214
+ }
215
+ delete(e, t) {
216
+ return this.fetchExtended({
217
+ url: e,
218
+ method: "DELETE",
219
+ options: t
220
+ });
221
+ }
222
+ getAbsoluteUrl(e) {
223
+ return `https://${this.baseUrl}${e}`;
224
+ }
225
+ }, _e = (e) => {
226
+ let t = A(n(e, "package.json"));
227
+ t.name = e;
228
+ }, ve = (e) => e ? /^[_a-z-]+$/.test(e) ? de(e) ? !0 : `The directory ./${e} already exist.` : "The project name needs to be \"a-z\" separated by \"-\" or \"_\"." : "The content block name can not be empty.", ye = class extends Error {
229
+ name = "CommandExecutionError";
230
+ constructor(e) {
231
+ super(), O.error(`The command execution failed: ${e}`);
232
+ }
233
+ }, I = (e, t = {}) => new Promise((n, r) => {
234
+ _(e, t, (e, t) => e ? r(new ye(e + t)) : n(t));
235
+ }), be = class extends Error {
236
+ name = "InvalidInstanceUrlError";
237
+ constructor(e) {
238
+ super(), e ? O.error(`The given URL "${e}" is invalid.`) : O.error("No instance URL was given.");
239
+ }
240
+ }, L = (e) => {
241
+ try {
242
+ return new te(`https://${e.replace(/^https?:\/\//, "")}`).hostname;
243
+ } catch {
244
+ throw new be(e);
245
+ }
246
+ }, R = async (e, t) => {
247
+ let n = new F(e), r = t || N.get("tokens.access_token");
248
+ try {
249
+ return (await n.post("/graphql", { query: "{ currentUser { email name } }" }, { headers: { Authorization: `Bearer ${r}` } })).data.currentUser;
250
+ } catch {
251
+ O.error(`You are currently not logged in. You can use the command ${c.bold("frontify-cli login")} to log in.`);
252
+ return;
253
+ }
254
+ }, xe = (e, n) => {
255
+ m(t(e, ".gitignore"), Se[n]);
256
+ }, Se = {
257
+ "platform-app": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\npnpm-debug.log*\nlerna-debug.log*\n\nnode_modules\ndist\ndist-ssr\n*.localdist\n.idea\n.vscode\n\n# Editor directories and files\n.DS_Store\n*.suo\n*.ntvs*\n*.njsproj\n*.sln\n*.sw?\n.secret.json\n",
258
+ "content-block": "node_modules\ndist\n.idea\n.vscode\n"
259
+ }, Ce = async ({ outputName: e, entryFile: t, projectPath: n = "" }) => {
260
+ let r = j(n), i = await y({
261
+ plugins: [v(), re({
262
+ react: "React",
263
+ "react-dom": "ReactDOM"
264
+ })],
265
+ root: n,
266
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
267
+ build: {
268
+ lib: {
269
+ entry: t,
270
+ name: e,
271
+ formats: ["iife"],
272
+ fileName: () => "index.js"
273
+ },
274
+ rollupOptions: {
275
+ external: ["react", "react-dom"],
276
+ output: {
277
+ globals: {
278
+ react: "React",
279
+ "react-dom": "ReactDOM"
280
+ },
281
+ entryFileNames: "settings.js",
282
+ footer: `
283
283
  window.${e} = ${e};
284
284
  window.${e}.dependencies = window.${e}.packages || {};
285
285
  window.${e}.dependencies['@frontify/app-bridge'] = '${r}';
286
286
  `
287
- }
288
- }
289
- }
290
- });
291
- return { app: await A({
292
- plugins: [x()],
293
- root: n,
294
- define: {
295
- "process.env.NODE_ENV": JSON.stringify("production")
296
- },
297
- base: "/__DYNAMIC_SEGMENT__/",
298
- build: {
299
- emptyOutDir: !1
300
- }
301
- }), settings: o };
302
- }, se = async ({ projectPath: e, entryFile: t, outputName: n }) => {
303
- const r = L(e);
304
- return A({
305
- plugins: [
306
- x(),
307
- C({
308
- react: "React",
309
- "react-dom": "ReactDOM"
310
- })
311
- ],
312
- define: {
313
- "process.env.NODE_ENV": JSON.stringify("production")
314
- },
315
- root: e,
316
- build: {
317
- lib: {
318
- name: n,
319
- entry: t,
320
- formats: ["iife"],
321
- fileName: () => "index.js"
322
- },
323
- rollupOptions: {
324
- external: ["react", "react-dom"],
325
- output: {
326
- globals: {
327
- react: "React",
328
- "react-dom": "ReactDOM"
329
- },
330
- footer: `
331
- window.${n} = ${n};
332
- window.${n}.dependencies = window.${n}.packages || {};
333
- window.${n}.dependencies['@frontify/app-bridge'] = '${r}';
334
- `
335
- }
336
- }
337
- }
338
- });
339
- }, ae = (e) => $(m(e, "package.json")).dependencies["@frontify/app-bridge-theme"], ie = async ({ projectPath: e, entryFile: t, outputName: n }) => {
340
- const r = ae(e);
341
- return A({
342
- plugins: [
343
- x(),
344
- C({
345
- react: "React",
346
- "react-dom": "ReactDOM"
347
- })
348
- ],
349
- define: {
350
- "process.env.NODE_ENV": JSON.stringify("production")
351
- },
352
- root: e,
353
- build: {
354
- lib: {
355
- name: n,
356
- entry: t,
357
- formats: ["iife"],
358
- fileName: () => "index.js"
359
- },
360
- rollupOptions: {
361
- external: ["react", "react-dom"],
362
- output: {
363
- globals: {
364
- react: "React",
365
- "react-dom": "ReactDOM"
366
- },
367
- footer: `
368
- window.${n} = ${n};
369
- window.${n}.dependencies = window.${n}.packages || {};
370
- window.${n}.dependencies['@frontify/app-bridge-theme'] = '${r}';
371
- `
372
- }
373
- }
374
- }
375
- });
376
- }, g = ["exe", "dmg", "cmd", "sh", "bat"], v = (e) => `Invalid file extension, \`${e}.filenameExtension\` can not include: ${g.join(", ")}.`, T = c({
377
- title: a().min(1).max(40)
378
- }).optional(), P = w.enum(["audio", "document", "image", "video", "file", "embeddedContent"]), z = P.exclude(["audio", "document", "video", "file", "embeddedContent"]), H = w.enum(["svg"]), Y = w.enum(["svg", "jpg", "jpeg", "ai", "eps", "png", "tif", "tiff"]), et = w.enum(["content-block", "platform-app", "theme"]), q = /* @__PURE__ */ new Set(), tt = c({
379
- label: a(),
380
- key: a().min(1).max(80).refine(
381
- (e) => q.has(e) ? !1 : (q.add(e), /^\w+$/.test(e)),
382
- {
383
- message: "Secret Key must be unique and should only contain letters from a-z, A-Z, numbers from 0-9 and '_' without any spaces"
384
- }
385
- )
386
- }), nt = l(tt), rt = c({
387
- method: w.enum(["GET", "POST", "PUT", "DELETE"]),
388
- headers: w.record(a()).optional(),
389
- body: w.any().optional()
390
- }), Z = /* @__PURE__ */ new Set(), ot = c({
391
- name: a().refine(
392
- (e) => Z.has(e) ? !1 : (Z.add(e), /^[\w-]*$/.test(e)),
393
- {
394
- message: "Endpoint name must be unique"
395
- }
396
- ),
397
- resource: a(),
398
- options: rt
399
- }), st = /^(([\dA-Za-z]|[\dA-Za-z][\dA-Za-z-]*[\dA-Za-z])\.)*([\dA-Za-z]|[\dA-Za-z][\dA-Za-z-]*[\dA-Za-z])$/, at = w.enum(["basic:read", "basic:write", "account:read", "webhook:read", "webhook:write"]), it = c({
400
- permissions: c({
401
- scopes: l(at).min(1, "At least one scope is required").max(5, "No more than 5 scopes are allowed").refine((e) => e.includes("basic:read"), {
402
- message: "'basic:read' is required in scopes"
403
- })
404
- }).optional()
405
- }).optional(), K = c({
406
- key: a(),
407
- type: a(),
408
- label: a()
409
- }), ct = c({
410
- id: a(),
411
- title: a(),
412
- iconUrl: a(),
413
- returns: l(K),
414
- version: te().int().positive(),
415
- externalId: a(),
416
- parameters: l(K)
417
- }), lt = l(ct).optional(), pt = c({
418
- appId: a().length(25),
419
- appType: et,
420
- experimental: Se().optional(),
421
- secrets: nt.optional(),
422
- network: c({
423
- allowedHosts: l(
424
- a().refine((e) => st.test(e), {
425
- message: "Invalid host format"
426
- })
427
- ).optional(),
428
- endpoints: l(ot).optional()
429
- }).optional(),
430
- permissionsSchema: it,
431
- automation: c({
432
- actions: lt
433
- }).optional(),
434
- surfaces: c({
435
- guideline: c({
436
- pageAction: c({
437
- title: a().min(2).max(28)
438
- }).optional(),
439
- assetViewer: c({
440
- title: a().min(2).max(28),
441
- type: l(P),
442
- filenameExtension: l(
443
- a().refine((e) => !g.includes(e), {
444
- message: v("guideline")
445
- })
446
- )
447
- }).optional()
448
- }).optional(),
449
- mediaLibrary: c({
450
- assetBulkActions: c({
451
- title: a().min(2).max(28),
452
- filenameExtensions: l(
453
- a().refine((e) => !g.includes(e), {
454
- message: v("mediaLibrary")
455
- })
456
- )
457
- }).optional(),
458
- assetAction: c({
459
- title: a().min(2).max(28),
460
- type: l(P),
461
- filenameExtension: l(
462
- a().refine((e) => !g.includes(e), {
463
- message: v("mediaLibrary")
464
- })
465
- )
466
- }).optional(),
467
- assetCreation: T
468
- }).optional(),
469
- iconLibrary: c({
470
- assetBulkActions: c({
471
- title: a().min(2).max(28),
472
- filenameExtensions: l(H)
473
- }).optional(),
474
- assetAction: c({
475
- title: a().min(2).max(28),
476
- type: l(z),
477
- filenameExtension: l(H)
478
- }).optional(),
479
- assetCreation: T
480
- }).optional(),
481
- logoLibrary: c({
482
- assetBulkActions: c({
483
- title: a().min(2).max(28),
484
- filenameExtensions: l(Y)
485
- }).optional(),
486
- assetAction: c({
487
- title: a().min(2).max(28),
488
- type: l(z),
489
- filenameExtension: l(Y)
490
- }).optional(),
491
- assetCreation: T
492
- }).optional(),
493
- documentLibrary: c({
494
- assetBulkActions: c({
495
- title: a().min(2).max(28),
496
- filenameExtensions: l(
497
- a().refine((e) => !g.includes(e), {
498
- message: v("documentLibrary")
499
- })
500
- )
501
- }).optional(),
502
- assetAction: c({
503
- title: a().min(2).max(28),
504
- type: l(P),
505
- filenameExtension: l(
506
- a().refine((e) => !g.includes(e), {
507
- message: v("documentLibrary")
508
- })
509
- )
510
- }).optional(),
511
- assetCreation: T
512
- }).optional(),
513
- workspace: c({
514
- assetBulkActions: c({
515
- title: a().min(2).max(28),
516
- filenameExtensions: l(
517
- a().refine((e) => !g.includes(e), {
518
- message: v("workspaceProject")
519
- })
520
- )
521
- }).optional(),
522
- assetAction: c({
523
- title: a().min(2).max(28),
524
- type: l(P),
525
- filenameExtension: l(
526
- a().refine((e) => !g.includes(e), {
527
- message: v("workspaceProject")
528
- })
529
- )
530
- }).optional(),
531
- assetCreation: T
532
- }).optional()
533
- }).optional(),
534
- metadata: c({
535
- version: te().int()
536
- })
537
- }), dt = (e, t) => {
538
- const n = t.safeParse(e);
539
- if (!n.success)
540
- throw new Error(n.error.message);
541
- return n.data;
542
- }, G = async (e, t) => {
543
- const n = await E(`${E.convertPathToPattern(e)}/**`, { ignore: t, dot: !0 });
544
- return n.map((o) => o.replace(`${e}/`, "")).reduce((o, i, p) => (o[`/${i}`] = ze(n[p]), o), {});
545
- }, mt = ["**/*.*.map"], ft = [
546
- ".git",
547
- "node_modules",
548
- "dist",
549
- ".vscode",
550
- ".idea",
551
- ".eslintignore",
552
- ".prettierignore",
553
- "README.md",
554
- ".DS_Store",
555
- "**/*.graphql"
556
- ], D = async (e, t, { dryRun: n = !1, noVerify: r = !1, openInBrowser: o = !1, token: i, instance: p }, u) => {
557
- try {
558
- let h;
559
- const S = p || k.get("instanceUrl"), J = i || k.get("tokens.access_token");
560
- if ((!J || !S) && (s.error(
561
- `You are currently not logged in. You can use the command ${b.bold(
562
- "frontify-cli login"
563
- )} to log in, or pass --token=<token> --instance=<instance> to the deploy command.`
564
- ), process.exit(-1)), n || (h = await oe(S, i), h && s.info(`You are logged in as ${h.name} (${S}).`)), h || n) {
565
- n && s.info(b.blue("Dry run: enabled"));
566
- const y = process.cwd(), R = $(m(y, "manifest.json")), { appId: _ } = R.appType === "platform-app" ? dt(R, pt) : R;
567
- r || (s.info("Performing type checks..."), await M("npx tsc --noEmit"), s.info("Performing eslint checks..."), await M("npx eslint src"));
568
- try {
569
- await u({ projectPath: y, entryFile: e, outputName: _ });
570
- } catch (d) {
571
- s.error(d), process.exit(-1);
572
- }
573
- const pe = mt.map(
574
- (d) => E.convertPathToPattern(y + d)
575
- ), de = [...He(m(y, ".gitignore")).filter(
576
- (d) => d !== "manifest.json"
577
- ), ...ft].map((d) => d.includes("*") ? `${y}/${d}` : E.convertPathToPattern(`${y}/${d}`)), me = {
578
- build_files: await G(
579
- E.convertPathToPattern(`${y}/${t}`),
580
- pe
581
- ),
582
- source_files: await G(E.convertPathToPattern(y), de)
583
- };
584
- if (n)
585
- s.success("The command has been executed without any issue."), process.exit(0);
586
- else {
587
- s.info("Sending the files to Frontify Marketplace...");
588
- const d = new V(S);
589
- try {
590
- await d.put(`/api/marketplace/app/${_}`, me, {
591
- headers: { Authorization: `Bearer ${J}` }
592
- }), s.success("The new version has been pushed."), o && (s.info("Opening the Frontify Marketplace page..."), await Q(`https://${S}/marketplace/apps/${_}`));
593
- } catch (fe) {
594
- s.error("An error occured while deploying:", fe.responseBody.error), process.exit(-1);
595
- }
596
- }
597
- }
598
- } catch (h) {
599
- typeof h == "string" ? s.error("The deployment has failed and was aborted due to an error:", h) : h instanceof Error ? s.error("The deployment has failed and was aborted due to an error:", h.message) : s.error("The deployment has failed and was aborted due to an unknown error."), process.exit(-1);
600
- }
601
- };
602
- class ut {
603
- constructor(t, n = 5600) {
604
- this.fastifyServer = Pe(), this.instanceUrl = t, this.port = n, this.httpClient = new V(t);
605
- }
606
- serveCallbackServer() {
607
- this.registerPlugins(), this.registerRoutes(), this.fastifyServer.listen({ port: this.port });
608
- }
609
- registerRoutes() {
610
- this.fastifyServer.get("/oauth", async (t, n) => {
611
- s.info("Access granted, getting access token..."), n.send("You can close this window.");
612
- const r = await this.getOauthCredentialDetails(t.query.code);
613
- s.info("Tokens received, storing tokens..."), k.set("tokens", r), k.set("instanceUrl", this.instanceUrl);
614
- const o = await oe(this.instanceUrl);
615
- o && s.success(`Welcome back ${o.name} (${this.instanceUrl})!`), process.exit(0);
616
- });
617
- }
618
- registerPlugins() {
619
- this.fastifyServer.register(Te);
620
- }
621
- async storeRandomCodeChallenge() {
622
- try {
623
- const t = await this.httpClient.get(
624
- "/api/oauth/random"
625
- );
626
- this.randomChallenge = t.data;
627
- } catch (t) {
628
- const n = t instanceof Error ? t.message : String(t);
629
- throw new Error(`An error occurred while getting the random challenge: ${n}`);
630
- }
631
- }
632
- getLoginUrl() {
633
- if (!this.randomChallenge)
634
- throw new Error("Random challenge needs to be defined.");
635
- const t = [
636
- "response_type=code",
637
- "client_id=block-cli",
638
- "redirect_uri=http://localhost:5600/oauth",
639
- "scope=basic:read%2Bblocks:read%2Bblocks:write",
640
- `code_challenge=${this.randomChallenge.sha256}`,
641
- "code_challenge_method=S256"
642
- ].join("&");
643
- return `https://${this.instanceUrl}/api/oauth/authorize?${t}`;
644
- }
645
- async getOauthCredentialDetails(t) {
646
- if (!this.randomChallenge)
647
- throw new Error("Random challenge needs to be defined.");
648
- try {
649
- return await this.httpClient.post("/api/oauth/accesstoken", {
650
- grant_type: "authorization_code",
651
- client_id: "block-cli",
652
- redirect_uri: "http://localhost:5600/oauth",
653
- scope: "basic:read+blocks:read+blocks:write",
654
- code_verifier: this.randomChallenge.secret,
655
- code: t
656
- });
657
- } catch (n) {
658
- const r = n instanceof Error ? n.message : String(n);
659
- throw new Error(`An error occurred while getting tokens: ${r}`);
660
- }
661
- }
287
+ }
288
+ }
289
+ }
290
+ });
291
+ return {
292
+ app: await y({
293
+ plugins: [v()],
294
+ root: n,
295
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
296
+ base: "/__DYNAMIC_SEGMENT__/",
297
+ build: { emptyOutDir: !1 }
298
+ }),
299
+ settings: i
300
+ };
301
+ }, z = [
302
+ "react",
303
+ "react/jsx-runtime",
304
+ "react/jsx-dev-runtime",
305
+ "react-dom",
306
+ "react-dom/client"
307
+ ];
308
+ function B() {
309
+ let e = /* @__PURE__ */ new Set(), t = [...z];
310
+ return {
311
+ name: "vite-plugin-react-bare-external",
312
+ enforce: "pre",
313
+ apply: "serve",
314
+ config(n) {
315
+ n.optimizeDeps ??= {}, n.optimizeDeps.exclude = [...n.optimizeDeps.exclude ?? [], ...t];
316
+ let r = n.optimizeDeps;
317
+ return r.rolldownOptions ??= {}, r.rolldownOptions.plugins ??= [], r.rolldownOptions.plugins.push({
318
+ name: "externalize-react",
319
+ resolveId(n) {
320
+ return t.includes(n) ? (e.add(n), {
321
+ id: n,
322
+ external: !0
323
+ }) : null;
324
+ }
325
+ }), r.rolldownOptions.plugins.push(x({ external: t })), null;
326
+ },
327
+ configResolved(t) {
328
+ let n = (t.base ?? "/").replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
329
+ t.plugins.push({
330
+ name: "vite-plugin-react-bare-restore",
331
+ transform(t) {
332
+ if (e.size === 0) return null;
333
+ let r = RegExp(`${n}@id\\/(${[...e].join("|")})`, "g");
334
+ return t.replace(r, (e, t) => t);
335
+ }
336
+ });
337
+ },
338
+ resolveId(n) {
339
+ return t.includes(n) ? (e.add(n), {
340
+ id: n,
341
+ external: !0
342
+ }) : null;
343
+ },
344
+ load(t) {
345
+ return e.has(t) ? "export default {};" : null;
346
+ }
347
+ };
662
348
  }
663
- const ht = async (e, t) => {
664
- try {
665
- const n = re(e), r = new ut(n, t);
666
- r.serveCallbackServer(), await r.storeRandomCodeChallenge();
667
- const o = r.getLoginUrl();
668
- s.info("Attempting to open OAuth login page..."), s.info(
669
- `If a browser window doesn't automatically open, please open the following link manually: ${o}`
670
- ), await Q(o);
671
- } catch (n) {
672
- const r = n instanceof Error ? n.message : String(n);
673
- s.error(`You need to enter a valid Frontify instance URL: ${r}`), process.exit(-1);
674
- }
675
- }, yt = () => {
676
- k.delete("tokens"), s.info("You are now logged out.");
677
- };
678
- class gt {
679
- constructor(t, n, r) {
680
- this.entryFilePath = t, this.port = n, this.allowExternal = r;
681
- }
682
- async serve() {
683
- try {
684
- const t = await B({
685
- root: process.cwd(),
686
- plugins: [
687
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
688
- // @ts-ignore
689
- x(),
690
- C({
691
- react: "React",
692
- "react-dom": "ReactDOM"
693
- })
694
- ],
695
- define: {
696
- "process.env.NODE_ENV": JSON.stringify("development"),
697
- "DevCustomBlock.dependencies.appBridge": JSON.stringify(L(process.cwd()))
698
- },
699
- base: `http://localhost:${this.port}/`,
700
- appType: "custom",
701
- server: {
702
- port: this.port,
703
- host: this.allowExternal ? "0.0.0.0" : "localhost",
704
- cors: !0,
705
- hmr: {
706
- port: this.port,
707
- host: this.allowExternal ? "0.0.0.0" : "localhost",
708
- protocol: "ws"
709
- }
710
- }
711
- });
712
- t.middlewares.use("/", (r, o, i) => r.url !== "/" ? i() : (o.writeHead(200), o.end("OK"))), t.middlewares.use("/_entrypoint", (r, o, i) => r.url !== "/" ? i() : (o.setHeader("Content-Type", "application/json"), o.writeHead(200), o.end(
713
- JSON.stringify({
714
- url: `http://localhost:${this.port}/${this.entryFilePath}`,
715
- entryFilePath: this.entryFilePath,
716
- port: this.port,
717
- version: F.version
718
- })
719
- ))), (await t.listen(this.port, !0)).printUrls();
720
- } catch (t) {
721
- console.error(t), process.exit(1);
722
- }
723
- }
724
- }
725
- class wt {
726
- constructor(t, n) {
727
- this.entryFilePath = t, this.port = n;
728
- }
729
- async serve() {
730
- try {
731
- const t = await Ce.context({
732
- entryPoints: [this.entryFilePath],
733
- outfile: "./dist/dev-settings.js",
734
- minify: !0,
735
- globalName: "devSettings",
736
- format: "iife",
737
- bundle: !0,
738
- loader: {
739
- ".css": "empty"
740
- }
741
- });
742
- (await (await B({
743
- root: process.cwd(),
744
- configFile: !1,
745
- define: {
746
- "process.env.NODE_ENV": JSON.stringify("development")
747
- },
748
- server: { cors: !0 },
749
- plugins: [
750
- x(),
751
- {
752
- name: "prebuild-commands",
753
- handleHotUpdate: ({ file: o, server: i }) => {
754
- const p = ue.relative(process.cwd(), o);
755
- (p === "src/settings.ts" || p === "src/index.ts") && (t.rebuild(), i.restart());
756
- },
757
- buildStart: () => {
758
- t.rebuild();
759
- }
760
- }
761
- ]
762
- })).listen(this.port, !0)).printUrls();
763
- } catch (t) {
764
- console.error(t), process.exit(1);
765
- }
766
- }
767
- }
768
- class vt {
769
- constructor(t, n, r) {
770
- this.entryFilePath = t, this.port = n, this.allowExternal = r;
771
- }
772
- async serve() {
773
- try {
774
- const t = await B({
775
- root: process.cwd(),
776
- plugins: [
777
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
778
- // @ts-ignore
779
- x(),
780
- C({
781
- react: "React",
782
- "react-dom": "ReactDOM"
783
- })
784
- ],
785
- define: {
786
- "process.env.NODE_ENV": JSON.stringify("development"),
787
- "DevCustomTheme.dependencies.appBridgeTheme": JSON.stringify(
788
- ae(process.cwd())
789
- )
790
- },
791
- base: `http://localhost:${this.port}/`,
792
- appType: "custom",
793
- server: {
794
- port: this.port,
795
- host: this.allowExternal ? "0.0.0.0" : "localhost",
796
- cors: !0,
797
- hmr: {
798
- port: this.port,
799
- host: this.allowExternal ? "0.0.0.0" : "localhost",
800
- protocol: "ws"
801
- }
802
- }
803
- });
804
- t.middlewares.use("/", (r, o, i) => r.url !== "/" ? i() : (o.writeHead(200), o.end("OK"))), t.middlewares.use("/_entrypoint", (r, o, i) => r.url !== "/" ? i() : (o.setHeader("Content-Type", "application/json"), o.writeHead(200), o.end(
805
- JSON.stringify({
806
- url: `http://localhost:${this.port}/${this.entryFilePath}`,
807
- entryFilePath: this.entryFilePath,
808
- port: this.port,
809
- version: F.version
810
- })
811
- ))), (await t.listen(this.port, !0)).printUrls();
812
- } catch (t) {
813
- console.error(t), process.exit(1);
814
- }
815
- }
816
- }
817
- const ce = async (e, t, n) => {
818
- s.info("Starting the development server..."), await new gt(e, t, n).serve();
819
- }, bt = async (e, t, n) => {
820
- s.info("Starting the development server for theme..."), await new vt(e, t, n).serve();
821
- }, xt = async (e, t) => {
822
- s.info("Starting the development server for Apps..."), await new wt(e, t).serve();
823
- }, le = (e, t, n) => {
824
- s.info(`Creating the ${n}...`);
825
- const r = b.blue(`./${e}`);
826
- s.info(`Scaffolding App in ${r}...`);
827
- const o = O($e(import.meta.url), `../../templates/${n}-${t}`);
828
- ne(o, e, { exclude: ["node_modules"] }), We(e, n), qe(e), s.defaultInfo(`
829
- ${s.spacer(11)}You can now access the project and install dependencies.`);
830
- const i = b.blue(`./${e}`);
831
- s.defaultInfo(`${s.spacer(4)}cd ${i}`), s.defaultInfo(`${s.spacer(4)}npm i`), s.defaultInfo(`${s.spacer(4)}npm run serve`), s.defaultInfo(`
832
- ${s.spacer(11)}Happy hacking!`);
833
- }, f = he(F.name.split("/")[1]);
834
- f.command("login [instanceUrl]", "log in to a Frontify instance").option("-i, --instance <instanceUrl>", "[string] url of the Frontify instance").option("-p, --port <port>", "[number] port for the oauth service", {
835
- default: process.env.PORT || 5600
836
- }).action(async (e, t) => {
837
- const n = e || t.instance || process.env.INSTANCE_URL;
838
- n && j.inject([n]);
839
- const { promptedInstanceUrl: r } = await j([
840
- {
841
- type: "text",
842
- name: "promptedInstanceUrl",
843
- message: "Enter a Frontify instance URL",
844
- initial: "instanceName.frontify.com",
845
- validate: (i) => i.trim() === "" ? "You need to enter a valid URL." : !0
846
- }
847
- ]);
848
- r || W(0);
849
- const o = re(r);
850
- await ht(o, t.port);
349
+ //#endregion
350
+ //#region src/utils/compiler/compileBlock.ts
351
+ var V = async ({ projectPath: e, entryFile: t, outputName: n }) => y({
352
+ plugins: [v(), x({ external: z })],
353
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
354
+ root: e,
355
+ mode: "production",
356
+ build: {
357
+ minify: "terser",
358
+ cssMinify: "lightningcss",
359
+ lib: {
360
+ name: n,
361
+ entry: t,
362
+ formats: ["es"],
363
+ fileName: () => "index.js",
364
+ cssFileName: "style"
365
+ },
366
+ rolldownOptions: {
367
+ platform: "browser",
368
+ treeshake: { moduleSideEffects: [
369
+ {
370
+ test: /@frontify\/fondue-components/,
371
+ sideEffects: !1
372
+ },
373
+ {
374
+ test: /@frontify\/fondue-icons/,
375
+ sideEffects: !1
376
+ },
377
+ {
378
+ test: /@frontify\/fondue-tokens/,
379
+ sideEffects: !1
380
+ },
381
+ {
382
+ test: /@frontify\/fondue-charts/,
383
+ sideEffects: !1
384
+ },
385
+ {
386
+ test: /@frontify\/fondue-rte/,
387
+ sideEffects: !1
388
+ },
389
+ {
390
+ test: /\.css$/,
391
+ sideEffects: !0
392
+ }
393
+ ] }
394
+ }
395
+ }
396
+ }), H = async ({ projectPath: e, entryFile: t, outputName: n }) => y({
397
+ plugins: [v(), x({ external: z })],
398
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
399
+ root: e,
400
+ mode: "production",
401
+ build: {
402
+ minify: "terser",
403
+ cssMinify: "lightningcss",
404
+ lib: {
405
+ name: n,
406
+ entry: t,
407
+ formats: ["es"],
408
+ fileName: () => "index.js",
409
+ cssFileName: "style"
410
+ },
411
+ rolldownOptions: {
412
+ platform: "browser",
413
+ treeshake: { moduleSideEffects: [
414
+ {
415
+ test: /@frontify\/fondue-components/,
416
+ sideEffects: !1
417
+ },
418
+ {
419
+ test: /@frontify\/fondue-icons/,
420
+ sideEffects: !1
421
+ },
422
+ {
423
+ test: /@frontify\/fondue-tokens/,
424
+ sideEffects: !1
425
+ },
426
+ {
427
+ test: /@frontify\/fondue-charts/,
428
+ sideEffects: !1
429
+ },
430
+ {
431
+ test: /@frontify\/fondue-rte/,
432
+ sideEffects: !1
433
+ },
434
+ {
435
+ test: /\.css$/,
436
+ sideEffects: !0
437
+ }
438
+ ] }
439
+ }
440
+ }
441
+ }), U = [
442
+ "exe",
443
+ "dmg",
444
+ "cmd",
445
+ "sh",
446
+ "bat"
447
+ ], W = (e) => `Invalid file extension, \`${e}.filenameExtension\` can not include: ${U.join(", ")}.`, G = C({ title: w().min(1).max(40) }).optional(), K = T.enum([
448
+ "audio",
449
+ "document",
450
+ "image",
451
+ "video",
452
+ "file",
453
+ "embeddedContent"
454
+ ]), q = K.exclude([
455
+ "audio",
456
+ "document",
457
+ "video",
458
+ "file",
459
+ "embeddedContent"
460
+ ]), J = T.enum(["svg"]), Y = T.enum([
461
+ "svg",
462
+ "jpg",
463
+ "jpeg",
464
+ "ai",
465
+ "eps",
466
+ "png",
467
+ "tif",
468
+ "tiff"
469
+ ]), we = T.enum([
470
+ "content-block",
471
+ "platform-app",
472
+ "theme"
473
+ ]), X = /* @__PURE__ */ new Set(), Te = S(C({
474
+ label: w(),
475
+ key: w().min(1).max(80).refine((e) => X.has(e) ? !1 : (X.add(e), /^\w+$/.test(e)), { message: "Secret Key must be unique and should only contain letters from a-z, A-Z, numbers from 0-9 and '_' without any spaces" })
476
+ })), Ee = C({
477
+ method: T.enum([
478
+ "GET",
479
+ "POST",
480
+ "PUT",
481
+ "DELETE"
482
+ ]),
483
+ headers: T.record(w()).optional(),
484
+ body: T.any().optional()
485
+ }), Z = /* @__PURE__ */ new Set(), De = C({
486
+ name: w().refine((e) => Z.has(e) ? !1 : (Z.add(e), /^[\w-]*$/.test(e)), { message: "Endpoint name must be unique" }),
487
+ resource: w(),
488
+ options: Ee
489
+ }), Oe = /^(([\dA-Za-z]|[\dA-Za-z][\dA-Za-z-]*[\dA-Za-z])\.)*([\dA-Za-z]|[\dA-Za-z][\dA-Za-z-]*[\dA-Za-z])$/, ke = C({ permissions: C({ scopes: S(T.enum([
490
+ "basic:read",
491
+ "basic:write",
492
+ "account:read",
493
+ "webhook:read",
494
+ "webhook:write"
495
+ ])).min(1, "At least one scope is required").max(5, "No more than 5 scopes are allowed").refine((e) => e.includes("basic:read"), { message: "'basic:read' is required in scopes" }) }).optional() }).optional(), Ae = C({
496
+ key: w(),
497
+ type: w(),
498
+ label: w()
499
+ }), je = S(C({
500
+ id: w(),
501
+ title: w(),
502
+ iconUrl: w(),
503
+ returns: S(Ae),
504
+ version: ae().int().positive(),
505
+ externalId: w(),
506
+ parameters: S(Ae)
507
+ })).optional(), Me = C({
508
+ appId: w().length(25),
509
+ appType: we,
510
+ experimental: ie().optional(),
511
+ secrets: Te.optional(),
512
+ network: C({
513
+ allowedHosts: S(w().refine((e) => Oe.test(e), { message: "Invalid host format" })).optional(),
514
+ endpoints: S(De).optional()
515
+ }).optional(),
516
+ permissionsSchema: ke,
517
+ automation: C({ actions: je }).optional(),
518
+ surfaces: C({
519
+ guideline: C({
520
+ pageAction: C({ title: w().min(2).max(28) }).optional(),
521
+ assetViewer: C({
522
+ title: w().min(2).max(28),
523
+ type: S(K),
524
+ filenameExtension: S(w().refine((e) => !U.includes(e), { message: W("guideline") }))
525
+ }).optional()
526
+ }).optional(),
527
+ mediaLibrary: C({
528
+ assetBulkActions: C({
529
+ title: w().min(2).max(28),
530
+ filenameExtensions: S(w().refine((e) => !U.includes(e), { message: W("mediaLibrary") }))
531
+ }).optional(),
532
+ assetAction: C({
533
+ title: w().min(2).max(28),
534
+ type: S(K),
535
+ filenameExtension: S(w().refine((e) => !U.includes(e), { message: W("mediaLibrary") }))
536
+ }).optional(),
537
+ assetCreation: G
538
+ }).optional(),
539
+ iconLibrary: C({
540
+ assetBulkActions: C({
541
+ title: w().min(2).max(28),
542
+ filenameExtensions: S(J)
543
+ }).optional(),
544
+ assetAction: C({
545
+ title: w().min(2).max(28),
546
+ type: S(q),
547
+ filenameExtension: S(J)
548
+ }).optional(),
549
+ assetCreation: G
550
+ }).optional(),
551
+ logoLibrary: C({
552
+ assetBulkActions: C({
553
+ title: w().min(2).max(28),
554
+ filenameExtensions: S(Y)
555
+ }).optional(),
556
+ assetAction: C({
557
+ title: w().min(2).max(28),
558
+ type: S(q),
559
+ filenameExtension: S(Y)
560
+ }).optional(),
561
+ assetCreation: G
562
+ }).optional(),
563
+ documentLibrary: C({
564
+ assetBulkActions: C({
565
+ title: w().min(2).max(28),
566
+ filenameExtensions: S(w().refine((e) => !U.includes(e), { message: W("documentLibrary") }))
567
+ }).optional(),
568
+ assetAction: C({
569
+ title: w().min(2).max(28),
570
+ type: S(K),
571
+ filenameExtension: S(w().refine((e) => !U.includes(e), { message: W("documentLibrary") }))
572
+ }).optional(),
573
+ assetCreation: G
574
+ }).optional(),
575
+ workspace: C({
576
+ assetBulkActions: C({
577
+ title: w().min(2).max(28),
578
+ filenameExtensions: S(w().refine((e) => !U.includes(e), { message: W("workspaceProject") }))
579
+ }).optional(),
580
+ assetAction: C({
581
+ title: w().min(2).max(28),
582
+ type: S(K),
583
+ filenameExtension: S(w().refine((e) => !U.includes(e), { message: W("workspaceProject") }))
584
+ }).optional(),
585
+ assetCreation: G
586
+ }).optional()
587
+ }).optional(),
588
+ metadata: C({ version: ae().int() })
589
+ }), Ne = (e, t) => {
590
+ let n = t.safeParse(e);
591
+ if (!n.success) throw Error(n.error.message);
592
+ return n.data;
593
+ }, Pe = async (e, t) => {
594
+ let n = await o(`${o.convertPathToPattern(e)}/**`, {
595
+ ignore: t,
596
+ dot: !0
597
+ });
598
+ return n.map((t) => t.replace(`${e}/`, "")).reduce((e, t, r) => (e[`/${t}`] = me(n[r]), e), {});
599
+ }, Fe = ["**/*.*.map"], Ie = [
600
+ ".git",
601
+ "node_modules",
602
+ "dist",
603
+ ".vscode",
604
+ ".idea",
605
+ ".eslintignore",
606
+ ".prettierignore",
607
+ "README.md",
608
+ ".DS_Store",
609
+ "**/*.graphql"
610
+ ], Q = async (e, n, { dryRun: r = !1, noVerify: i = !1, openInBrowser: a = !1, token: l, instance: u }, d) => {
611
+ try {
612
+ let f, p = u || N.get("instanceUrl"), m = l || N.get("tokens.access_token");
613
+ if ((!m || !p) && (O.error(`You are currently not logged in. You can use the command ${c.bold("frontify-cli login")} to log in, or pass --token=<token> --instance=<instance> to the deploy command.`), process.exit(-1)), r || (f = await R(p, l), f && O.info(`You are logged in as ${f.name} (${p}).`)), f || r) {
614
+ r && O.info(c.blue("Dry run: enabled"));
615
+ let l = process.cwd(), u = A(t(l, "manifest.json")), { appId: f } = u.appType === "platform-app" ? Ne(u, Me) : u;
616
+ i || (O.info("Performing type checks..."), await I("npx tsc --noEmit"), O.info("Performing eslint checks..."), await I("npx eslint src"));
617
+ try {
618
+ await d({
619
+ projectPath: l,
620
+ entryFile: e,
621
+ outputName: f
622
+ });
623
+ } catch (e) {
624
+ O.error(e), process.exit(-1);
625
+ }
626
+ let h = Fe.map((e) => o.convertPathToPattern(l + e)), ee = [...he(t(l, ".gitignore")).filter((e) => e !== "manifest.json"), ...Ie].map((e) => e.includes("*") ? `${l}/${e}` : o.convertPathToPattern(`${l}/${e}`)), g = A(t(l, "package.json")), _ = {
627
+ build_files: await Pe(o.convertPathToPattern(`${l}/${n}`), h),
628
+ source_files: await Pe(o.convertPathToPattern(l), ee),
629
+ dependencies: g?.dependencies || {}
630
+ };
631
+ if (r) O.success("The command has been executed without any issue."), process.exit(0);
632
+ else {
633
+ O.info("Sending the files to Frontify Marketplace...");
634
+ let e = new F(p);
635
+ try {
636
+ await e.put(`/api/marketplace/app/${f}`, _, { headers: { Authorization: `Bearer ${m}` } }), O.success("The new version has been pushed."), a && (O.info("Opening the Frontify Marketplace page..."), await s(`https://${p}/marketplace/apps/${f}`));
637
+ } catch (e) {
638
+ O.error("An error occured while deploying:", e.responseBody.error), process.exit(-1);
639
+ }
640
+ }
641
+ }
642
+ } catch (e) {
643
+ typeof e == "string" ? O.error("The deployment has failed and was aborted due to an error:", e) : e instanceof Error ? O.error("The deployment has failed and was aborted due to an error:", e.message) : O.error("The deployment has failed and was aborted due to an unknown error."), process.exit(-1);
644
+ }
645
+ }, Le = class {
646
+ instanceUrl;
647
+ port;
648
+ httpClient;
649
+ fastifyServer = se();
650
+ randomChallenge;
651
+ constructor(e, t = 5600) {
652
+ this.instanceUrl = e, this.port = t, this.httpClient = new F(e);
653
+ }
654
+ serveCallbackServer() {
655
+ this.registerPlugins(), this.registerRoutes(), this.fastifyServer.listen({ port: this.port });
656
+ }
657
+ registerRoutes() {
658
+ this.fastifyServer.get("/oauth", async (e, t) => {
659
+ O.info("Access granted, getting access token..."), t.send("You can close this window.");
660
+ let n = await this.getOauthCredentialDetails(e.query.code);
661
+ O.info("Tokens received, storing tokens..."), N.set("tokens", n), N.set("instanceUrl", this.instanceUrl);
662
+ let r = await R(this.instanceUrl);
663
+ r && O.success(`Welcome back ${r.name} (${this.instanceUrl})!`), process.exit(0);
664
+ });
665
+ }
666
+ registerPlugins() {
667
+ this.fastifyServer.register(oe);
668
+ }
669
+ async storeRandomCodeChallenge() {
670
+ try {
671
+ this.randomChallenge = (await this.httpClient.get("/api/oauth/random")).data;
672
+ } catch (e) {
673
+ let t = e instanceof Error ? e.message : String(e);
674
+ throw Error(`An error occurred while getting the random challenge: ${t}`);
675
+ }
676
+ }
677
+ getLoginUrl() {
678
+ if (!this.randomChallenge) throw Error("Random challenge needs to be defined.");
679
+ let e = [
680
+ "response_type=code",
681
+ "client_id=block-cli",
682
+ "redirect_uri=http://localhost:5600/oauth",
683
+ "scope=basic:read%2Bblocks:read%2Bblocks:write",
684
+ `code_challenge=${this.randomChallenge.sha256}`,
685
+ "code_challenge_method=S256"
686
+ ].join("&");
687
+ return `https://${this.instanceUrl}/api/oauth/authorize?${e}`;
688
+ }
689
+ async getOauthCredentialDetails(e) {
690
+ if (!this.randomChallenge) throw Error("Random challenge needs to be defined.");
691
+ try {
692
+ return await this.httpClient.post("/api/oauth/accesstoken", {
693
+ grant_type: "authorization_code",
694
+ client_id: "block-cli",
695
+ redirect_uri: "http://localhost:5600/oauth",
696
+ scope: "basic:read+blocks:read+blocks:write",
697
+ code_verifier: this.randomChallenge.secret,
698
+ code: e
699
+ });
700
+ } catch (e) {
701
+ let t = e instanceof Error ? e.message : String(e);
702
+ throw Error(`An error occurred while getting tokens: ${t}`);
703
+ }
704
+ }
705
+ }, Re = async (e, t) => {
706
+ try {
707
+ let n = new Le(L(e), t);
708
+ n.serveCallbackServer(), await n.storeRandomCodeChallenge();
709
+ let r = n.getLoginUrl();
710
+ O.info("Attempting to open OAuth login page..."), O.info(`If a browser window doesn't automatically open, please open the following link manually: ${r}`), await s(r);
711
+ } catch (e) {
712
+ let t = e instanceof Error ? e.message : String(e);
713
+ O.error(`You need to enter a valid Frontify instance URL: ${t}`), process.exit(-1);
714
+ }
715
+ }, ze = () => {
716
+ N.delete("tokens"), O.info("You are now logged out.");
717
+ }, Be = class {
718
+ constructor(e, t, n) {
719
+ this.entryFilePath = e, this.port = t, this.allowExternal = n;
720
+ }
721
+ async serve() {
722
+ try {
723
+ let e = j(process.cwd()), t = M(process.cwd()), n = await b({
724
+ root: process.cwd(),
725
+ plugins: [v(), B()],
726
+ define: { "process.env.NODE_ENV": JSON.stringify("development") },
727
+ base: `http://localhost:${this.port}/`,
728
+ appType: "custom",
729
+ server: {
730
+ port: this.port,
731
+ host: this.allowExternal ? "0.0.0.0" : "localhost",
732
+ cors: !0,
733
+ hmr: {
734
+ port: this.port,
735
+ host: this.allowExternal ? "0.0.0.0" : "localhost",
736
+ protocol: "ws"
737
+ },
738
+ forwardConsole: !1
739
+ }
740
+ });
741
+ n.middlewares.use("/", (e, t, n) => e.url === "/" ? (t.setHeader("Access-Control-Allow-Origin", "*"), t.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS"), t.writeHead(200), t.end("OK")) : n()), n.middlewares.use("/_entrypoint", (n, r, i) => {
742
+ if (n.url !== "/") return i();
743
+ let a = n.headers.host || `localhost:${this.port}`, o = parseInt(a.split(":")[1] || String(this.port), 10);
744
+ return r.setHeader("Access-Control-Allow-Origin", "*"), r.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS"), r.setHeader("Content-Type", "application/json"), r.writeHead(200), r.end(JSON.stringify({
745
+ url: `http://${a}/${this.entryFilePath}`,
746
+ entryFilePath: this.entryFilePath,
747
+ port: o,
748
+ version: E.version,
749
+ dependencies: {
750
+ ...e ? { "@frontify/app-bridge": e } : {},
751
+ react: t
752
+ }
753
+ }));
754
+ }), (await n.listen(this.port, !0)).printUrls();
755
+ } catch (e) {
756
+ console.error(e), process.exit(1);
757
+ }
758
+ }
759
+ }, Ve = class {
760
+ constructor(e, t) {
761
+ this.entryFilePath = e, this.port = t;
762
+ }
763
+ async serve() {
764
+ try {
765
+ let t = await ce.context({
766
+ entryPoints: [this.entryFilePath],
767
+ outfile: "./dist/dev-settings.js",
768
+ minify: !0,
769
+ globalName: "devSettings",
770
+ format: "iife",
771
+ bundle: !0,
772
+ loader: { ".css": "empty" }
773
+ });
774
+ (await (await b({
775
+ root: process.cwd(),
776
+ configFile: !1,
777
+ define: { "process.env.NODE_ENV": JSON.stringify("development") },
778
+ server: { cors: !0 },
779
+ plugins: [v(), {
780
+ name: "prebuild-commands",
781
+ handleHotUpdate: ({ file: n, server: r }) => {
782
+ let i = e.relative(process.cwd(), n);
783
+ (i === "src/settings.ts" || i === "src/index.ts") && (t.rebuild(), r.restart());
784
+ },
785
+ buildStart: () => {
786
+ t.rebuild();
787
+ }
788
+ }]
789
+ })).listen(this.port, !0)).printUrls();
790
+ } catch (e) {
791
+ console.error(e), process.exit(1);
792
+ }
793
+ }
794
+ }, He = class {
795
+ constructor(e, t, n) {
796
+ this.entryFilePath = e, this.port = t, this.allowExternal = n;
797
+ }
798
+ async serve() {
799
+ try {
800
+ let e = ue(process.cwd()), t = M(process.cwd()), n = await b({
801
+ root: process.cwd(),
802
+ plugins: [v(), B()],
803
+ define: { "process.env.NODE_ENV": JSON.stringify("development") },
804
+ base: `http://localhost:${this.port}/`,
805
+ appType: "custom",
806
+ server: {
807
+ port: this.port,
808
+ host: this.allowExternal ? "0.0.0.0" : "localhost",
809
+ cors: !0,
810
+ hmr: {
811
+ port: this.port,
812
+ host: this.allowExternal ? "0.0.0.0" : "localhost",
813
+ protocol: "ws"
814
+ },
815
+ forwardConsole: !1
816
+ }
817
+ });
818
+ n.middlewares.use("/", (e, t, n) => e.url === "/" ? (t.setHeader("Access-Control-Allow-Origin", "*"), t.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS"), t.writeHead(200), t.end("OK")) : n()), n.middlewares.use("/_entrypoint", (n, r, i) => {
819
+ if (n.url !== "/") return i();
820
+ let a = n.headers.host || `localhost:${this.port}`, o = parseInt(a.split(":")[1] || String(this.port), 10);
821
+ return r.setHeader("Access-Control-Allow-Origin", "*"), r.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS"), r.setHeader("Content-Type", "application/json"), r.writeHead(200), r.end(JSON.stringify({
822
+ url: `http://${a}/${this.entryFilePath}`,
823
+ entryFilePath: this.entryFilePath,
824
+ port: o,
825
+ version: E.version,
826
+ dependencies: {
827
+ ...e ? { "@frontify/app-bridge-theme": e } : {},
828
+ react: t
829
+ }
830
+ }));
831
+ }), (await n.listen(this.port, !0)).printUrls();
832
+ } catch (e) {
833
+ console.error(e), process.exit(1);
834
+ }
835
+ }
836
+ }, Ue = async (e, t, n) => {
837
+ O.info("Starting the development server..."), await new Be(e, t, n).serve();
838
+ }, We = async (e, t, n) => {
839
+ O.info("Starting the development server for theme..."), await new He(e, t, n).serve();
840
+ }, Ge = async (e, t) => {
841
+ O.info("Starting the development server for Apps..."), await new Ve(e, t).serve();
842
+ }, Ke = (e, t, r) => {
843
+ O.info(`Creating the ${r}...`);
844
+ let i = c.blue(`./${e}`);
845
+ O.info(`Scaffolding App in ${i}...`), P(n(ne(import.meta.url), `../../templates/${r}-${t}`), e, { exclude: ["node_modules"] }), xe(e, r), _e(e), O.defaultInfo(`\n${O.spacer(11)}You can now access the project and install dependencies.`);
846
+ let a = c.blue(`./${e}`);
847
+ O.defaultInfo(`${O.spacer(4)}cd ${a}`), O.defaultInfo(`${O.spacer(4)}npm i`), O.defaultInfo(`${O.spacer(4)}npm run serve`), O.defaultInfo(`\n${O.spacer(11)}Happy hacking!`);
848
+ }, $ = i(E.name.split("/")[1]);
849
+ $.command("login [instanceUrl]", "log in to a Frontify instance").option("-i, --instance <instanceUrl>", "[string] url of the Frontify instance").option("-p, --port <port>", "[number] port for the oauth service", { default: process.env.PORT || 5600 }).action(async (e, t) => {
850
+ let n = e || t.instance || process.env.INSTANCE_URL;
851
+ n && a.inject([n]);
852
+ let { promptedInstanceUrl: i } = await a([{
853
+ type: "text",
854
+ name: "promptedInstanceUrl",
855
+ message: "Enter a Frontify instance URL",
856
+ initial: "instanceName.frontify.com",
857
+ validate: (e) => e.trim() === "" ? "You need to enter a valid URL." : !0
858
+ }]);
859
+ i || r(0), await Re(L(i), t.port);
860
+ }), $.command("logout", "log out of an instance").action(ze);
861
+ for (let e of ["block", "theme"]) $.command(`${e} serve`, `[deprecated: use 'serve' instead] serve the ${e} locally`).alias(`${e} dev`).option("-e, --entryPath, --entry-path <entryPath>", `[string] path to the ${e} entry file`, { default: t("src", "index.tsx") }).option("--port <port>", "[number] specify port", { default: process.env.PORT || 5600 }).option("--allowExternal, --allow-external", "[boolean] allow external IPs to access the server", { default: !1 }).action(async (e) => {
862
+ await Ue(e.entryPath, e.port, e.allowExternal);
851
863
  });
852
- f.command("logout", "log out of an instance").action(yt);
853
- for (const e of ["block", "theme"])
854
- f.command(`${e} serve`, `[deprecated: use 'serve' instead] serve the ${e} locally`).alias(`${e} dev`).option("-e, --entryPath, --entry-path <entryPath>", `[string] path to the ${e} entry file`, {
855
- default: m("src", "index.tsx")
856
- }).option("--port <port>", "[number] specify port", {
857
- default: process.env.PORT || 5600
858
- }).option("--allowExternal, --allow-external", "[boolean] allow external IPs to access the server", {
859
- default: !1
860
- }).action(async (t) => {
861
- await ce(t.entryPath, t.port, t.allowExternal);
862
- });
863
- f.command("serve", "serve the app locally").alias("dev").option("-e, --entryPath, --entry-path <entryPath>", "[string] path to the entry file", {
864
- default: m("src", "index.ts")
865
- }).option("--port <port>", "[number] specify port", {
866
- default: process.env.PORT || 5600
867
- }).option("--allowExternal, --allow-external", "[boolean] allow external IPs to access the server", {
868
- default: !1
869
- }).option("--appType <appType>, --app-type", "[string] specify app type. Overrides manifest values").action(async (e) => {
870
- const t = $(m(process.cwd(), "manifest.json")), n = e.appType || t.appType;
871
- n === "platform-app" ? await xt(e.entryPath, e.port) : n === "theme" ? await bt(e.entryPath, e.port, e.allowExternal) : await ce(e.entryPath, e.port, e.allowExternal);
864
+ $.command("serve", "serve the app locally").alias("dev").option("-e, --entryPath, --entry-path <entryPath>", "[string] path to the entry file", { default: t("src", "index.ts") }).option("--port <port>", "[number] specify port", { default: process.env.PORT || 5600 }).option("--allowExternal, --allow-external", "[boolean] allow external IPs to access the server", { default: !1 }).option("--appType <appType>, --app-type", "[string] specify app type. Overrides manifest values").action(async (e) => {
865
+ let n = A(t(process.cwd(), "manifest.json")), r = e.appType || n.appType;
866
+ r === "platform-app" ? await Ge(e.entryPath, e.port) : r === "theme" ? await We(e.entryPath, e.port, e.allowExternal) : await Ue(e.entryPath, e.port, e.allowExternal);
872
867
  });
873
- for (const e of ["block", "theme"])
874
- f.command(`${e} deploy`, `[deprecated: use 'deploy' instead] deploy the ${e} to the marketplace`).option("-e, --entryPath <entryPath>", "[string] path to the entry file", { default: m("src", "index.tsx") }).option("-o, --outDir <outDir>", "[string] path to the output directory", { default: "dist" }).option("--dryRun, --dry-run", "[boolean] enable the dry run mode", { default: !1 }).option("--noVerify, --no-verify", "[boolean] disable the linting and typechecking", { default: !1 }).option("--open", "[boolean] open the marketplace app page", { default: !1 }).action(async (t) => {
875
- await D(
876
- t.entryPath,
877
- t.outDir,
878
- {
879
- dryRun: t.dryRun,
880
- noVerify: t.noVerify,
881
- openInBrowser: t.open
882
- },
883
- e === "theme" ? ie : se
884
- );
885
- });
886
- f.command("deploy", "deploy the app to the marketplace").option("-e, --entryPath <entryPath>", "[string] path to the entry file", { default: m("src", "index.ts") }).option("-o, --outDir <outDir>", "[string] path to the output directory", { default: "dist" }).option("--dryRun, --dry-run", "[boolean] enable the dry run mode", { default: !1 }).option("--noVerify, --no-verify", "[boolean] disable the linting and typechecking", { default: !1 }).option("--open", "[boolean] open the marketplace app page", { default: !1 }).option("--appType [appType], --app-type", "[string] specify app type. Overrides manifest values").option("-i, --instance <instanceUrl>", "[string] url of the Frontify instance").option("-t, --token <accessToken>", "[string] the access token").action(async (e) => {
887
- const t = $(m(process.cwd(), "manifest.json")), n = e.appType || t.appType;
888
- n === "platform-app" ? await D(
889
- e.entryPath,
890
- e.outDir,
891
- {
892
- dryRun: e.dryRun,
893
- noVerify: e.noVerify,
894
- openInBrowser: e.open,
895
- instance: e.instance,
896
- token: e.token
897
- },
898
- Xe
899
- ) : n === "theme" ? await D(
900
- e.entryPath,
901
- e.outDir,
902
- {
903
- dryRun: e.dryRun,
904
- noVerify: e.noVerify,
905
- openInBrowser: e.open,
906
- instance: e.instance,
907
- token: e.token
908
- },
909
- ie
910
- ) : await D(
911
- e.entryPath,
912
- e.outDir,
913
- {
914
- dryRun: e.dryRun,
915
- noVerify: e.noVerify,
916
- openInBrowser: e.open,
917
- instance: e.instance,
918
- token: e.token
919
- },
920
- se
921
- );
868
+ for (let e of ["block", "theme"]) $.command(`${e} deploy`, `[deprecated: use 'deploy' instead] deploy the ${e} to the marketplace`).option("-e, --entryPath <entryPath>", "[string] path to the entry file", { default: t("src", "index.tsx") }).option("-o, --outDir <outDir>", "[string] path to the output directory", { default: "dist" }).option("--dryRun, --dry-run", "[boolean] enable the dry run mode", { default: !1 }).option("--noVerify, --no-verify", "[boolean] disable the linting and typechecking", { default: !1 }).option("--open", "[boolean] open the marketplace app page", { default: !1 }).action(async (t) => {
869
+ await Q(t.entryPath, t.outDir, {
870
+ dryRun: t.dryRun,
871
+ noVerify: t.noVerify,
872
+ openInBrowser: t.open
873
+ }, e === "theme" ? H : V);
922
874
  });
923
- f.command("create [appName]", "create a new marketplace app").action(async (e) => {
924
- const { promptedAppName: t, stylingFramework: n, appType: r } = await j([
925
- {
926
- type: "text",
927
- name: "promptedAppName",
928
- message: "Enter your app name",
929
- initial: e || "my-frontify-app",
930
- validate: (o) => o.trim() === "" ? "You need to enter an app name." : Ze(o)
931
- },
932
- {
933
- type: "select",
934
- name: "appType",
935
- message: "Select the type of your app",
936
- choices: [
937
- { title: "App", value: "platform-app" },
938
- { title: "Block", value: "content-block" }
939
- ]
940
- },
941
- {
942
- type: "select",
943
- name: "stylingFramework",
944
- message: "Choose a styling framework",
945
- choices: [
946
- { title: "Tailwind", value: "tailwind" },
947
- { title: "CSS Modules", value: "css-modules" },
948
- { title: "None", value: "css" }
949
- ]
950
- }
951
- ]);
952
- (!t || !n || !r) && W(0), le(t, n, r);
875
+ $.command("deploy", "deploy the app to the marketplace").option("-e, --entryPath <entryPath>", "[string] path to the entry file", { default: t("src", "index.ts") }).option("-o, --outDir <outDir>", "[string] path to the output directory", { default: "dist" }).option("--dryRun, --dry-run", "[boolean] enable the dry run mode", { default: !1 }).option("--noVerify, --no-verify", "[boolean] disable the linting and typechecking", { default: !1 }).option("--open", "[boolean] open the marketplace app page", { default: !1 }).option("--appType [appType], --app-type", "[string] specify app type. Overrides manifest values").option("-i, --instance <instanceUrl>", "[string] url of the Frontify instance").option("-t, --token <accessToken>", "[string] the access token").action(async (e) => {
876
+ let n = A(t(process.cwd(), "manifest.json")), r = e.appType || n.appType;
877
+ r === "platform-app" ? await Q(e.entryPath, e.outDir, {
878
+ dryRun: e.dryRun,
879
+ noVerify: e.noVerify,
880
+ openInBrowser: e.open,
881
+ instance: e.instance,
882
+ token: e.token
883
+ }, Ce) : r === "theme" ? await Q(e.entryPath, e.outDir, {
884
+ dryRun: e.dryRun,
885
+ noVerify: e.noVerify,
886
+ openInBrowser: e.open,
887
+ instance: e.instance,
888
+ token: e.token
889
+ }, H) : await Q(e.entryPath, e.outDir, {
890
+ dryRun: e.dryRun,
891
+ noVerify: e.noVerify,
892
+ openInBrowser: e.open,
893
+ instance: e.instance,
894
+ token: e.token
895
+ }, V);
896
+ }), $.command("create [appName]", "create a new marketplace app").action(async (e) => {
897
+ let { promptedAppName: t, stylingFramework: n, appType: i } = await a([
898
+ {
899
+ type: "text",
900
+ name: "promptedAppName",
901
+ message: "Enter your app name",
902
+ initial: e || "my-frontify-app",
903
+ validate: (e) => e.trim() === "" ? "You need to enter an app name." : ve(e)
904
+ },
905
+ {
906
+ type: "select",
907
+ name: "appType",
908
+ message: "Select the type of your app",
909
+ choices: [{
910
+ title: "App",
911
+ value: "platform-app"
912
+ }, {
913
+ title: "Block",
914
+ value: "content-block"
915
+ }]
916
+ },
917
+ {
918
+ type: "select",
919
+ name: "stylingFramework",
920
+ message: "Choose a styling framework",
921
+ choices: [
922
+ {
923
+ title: "Tailwind",
924
+ value: "tailwind"
925
+ },
926
+ {
927
+ title: "CSS Modules",
928
+ value: "css-modules"
929
+ },
930
+ {
931
+ title: "None",
932
+ value: "css"
933
+ }
934
+ ]
935
+ }
936
+ ]);
937
+ (!t || !n || !i) && r(0), Ke(t, n, i);
953
938
  });
954
- for (const e of ["block", "theme"])
955
- f.command(
956
- `${e} create [appName]`,
957
- `[deprecated: use 'create' instead] create a ${e} app locally`
958
- ).action((t) => le(t, "css-modules", "content-block"));
959
- f.help();
960
- f.version(F.version);
961
- const Et = (e) => {
962
- const t = e.findIndex((n) => n === "block" || n === "theme");
963
- return t !== -1 && (e[t + 1] === "serve" || e[t + 1] === "deploy" || e[t + 1] === "create") && (e[t] = `${e[t]} ${e[t + 1]}`, e.splice(t + 1, 1)), e;
964
- };
965
- f.parse(Et(process.argv));
966
- //# sourceMappingURL=index.mjs.map
939
+ for (let e of ["block", "theme"]) $.command(`${e} create [appName]`, `[deprecated: use 'create' instead] create a ${e} app locally`).action((e) => Ke(e, "css-modules", "content-block"));
940
+ $.help(), $.version(E.version), $.parse(((e) => {
941
+ let t = e.findIndex((e) => e === "block" || e === "theme");
942
+ return t !== -1 && (e[t + 1] === "serve" || e[t + 1] === "deploy" || e[t + 1] === "create") && (e[t] = `${e[t]} ${e[t + 1]}`, e.splice(t + 1, 1)), e;
943
+ })(process.argv));
944
+ //#endregion
945
+
946
+ //# sourceMappingURL=index.mjs.map