@frontify/frontify-cli 5.10.1 → 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/README.md +1 -1
- package/dist/index.mjs +934 -1012
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
package/dist/index.mjs
CHANGED
|
@@ -1,1024 +1,946 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { exit as
|
|
4
|
-
import { cac as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
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
|
|
14
|
-
import { exec as
|
|
15
|
-
import { URL as
|
|
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
|
|
18
|
-
import { build as
|
|
19
|
-
import { viteExternalsPlugin as
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import * as
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
logs
|
|
284
|
-
*.log
|
|
285
|
-
npm-debug.log*
|
|
286
|
-
yarn-debug.log*
|
|
287
|
-
yarn-error.log*
|
|
288
|
-
pnpm-debug.log*
|
|
289
|
-
lerna-debug.log*
|
|
290
|
-
|
|
291
|
-
node_modules
|
|
292
|
-
dist
|
|
293
|
-
dist-ssr
|
|
294
|
-
*.localdist
|
|
295
|
-
.idea
|
|
296
|
-
.vscode
|
|
297
|
-
|
|
298
|
-
# Editor directories and files
|
|
299
|
-
.DS_Store
|
|
300
|
-
*.suo
|
|
301
|
-
*.ntvs*
|
|
302
|
-
*.njsproj
|
|
303
|
-
*.sln
|
|
304
|
-
*.sw?
|
|
305
|
-
.secret.json
|
|
306
|
-
`,
|
|
307
|
-
"content-block": `node_modules
|
|
308
|
-
dist
|
|
309
|
-
.idea
|
|
310
|
-
.vscode
|
|
311
|
-
`
|
|
312
|
-
}, Xe = async ({ outputName: e, entryFile: t, projectPath: n = "" }) => {
|
|
313
|
-
const r = L(n), o = await A({
|
|
314
|
-
plugins: [
|
|
315
|
-
x(),
|
|
316
|
-
C({
|
|
317
|
-
react: "React",
|
|
318
|
-
"react-dom": "ReactDOM"
|
|
319
|
-
})
|
|
320
|
-
],
|
|
321
|
-
root: n,
|
|
322
|
-
define: {
|
|
323
|
-
"process.env.NODE_ENV": JSON.stringify("production")
|
|
324
|
-
},
|
|
325
|
-
build: {
|
|
326
|
-
lib: {
|
|
327
|
-
entry: t,
|
|
328
|
-
name: e,
|
|
329
|
-
formats: ["iife"],
|
|
330
|
-
fileName: () => "index.js"
|
|
331
|
-
},
|
|
332
|
-
rollupOptions: {
|
|
333
|
-
external: ["react", "react-dom"],
|
|
334
|
-
output: {
|
|
335
|
-
globals: {
|
|
336
|
-
react: "React",
|
|
337
|
-
"react-dom": "ReactDOM"
|
|
338
|
-
},
|
|
339
|
-
entryFileNames: "settings.js",
|
|
340
|
-
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: `
|
|
341
283
|
window.${e} = ${e};
|
|
342
284
|
window.${e}.dependencies = window.${e}.packages || {};
|
|
343
285
|
window.${e}.dependencies['@frontify/app-bridge'] = '${r}';
|
|
344
286
|
`
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
],
|
|
407
|
-
define: {
|
|
408
|
-
"process.env.NODE_ENV": JSON.stringify("production")
|
|
409
|
-
},
|
|
410
|
-
root: e,
|
|
411
|
-
build: {
|
|
412
|
-
lib: {
|
|
413
|
-
name: n,
|
|
414
|
-
entry: t,
|
|
415
|
-
formats: ["iife"],
|
|
416
|
-
fileName: () => "index.js"
|
|
417
|
-
},
|
|
418
|
-
rollupOptions: {
|
|
419
|
-
external: ["react", "react-dom"],
|
|
420
|
-
output: {
|
|
421
|
-
globals: {
|
|
422
|
-
react: "React",
|
|
423
|
-
"react-dom": "ReactDOM"
|
|
424
|
-
},
|
|
425
|
-
footer: `
|
|
426
|
-
window.${n} = ${n};
|
|
427
|
-
window.${n}.dependencies = window.${n}.packages || {};
|
|
428
|
-
window.${n}.dependencies['@frontify/app-bridge-theme'] = '${r}';
|
|
429
|
-
`
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}, g = ["exe", "dmg", "cmd", "sh", "bat"], v = (e) => `Invalid file extension, \`${e}.filenameExtension\` can not include: ${g.join(", ")}.`, T = c({
|
|
435
|
-
title: a().min(1).max(40)
|
|
436
|
-
}).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({
|
|
437
|
-
label: a(),
|
|
438
|
-
key: a().min(1).max(80).refine(
|
|
439
|
-
(e) => q.has(e) ? !1 : (q.add(e), /^\w+$/.test(e)),
|
|
440
|
-
{
|
|
441
|
-
message: "Secret Key must be unique and should only contain letters from a-z, A-Z, numbers from 0-9 and '_' without any spaces"
|
|
442
|
-
}
|
|
443
|
-
)
|
|
444
|
-
}), nt = l(tt), rt = c({
|
|
445
|
-
method: w.enum(["GET", "POST", "PUT", "DELETE"]),
|
|
446
|
-
headers: w.record(a()).optional(),
|
|
447
|
-
body: w.any().optional()
|
|
448
|
-
}), Z = /* @__PURE__ */ new Set(), ot = c({
|
|
449
|
-
name: a().refine(
|
|
450
|
-
(e) => Z.has(e) ? !1 : (Z.add(e), /^[\w-]*$/.test(e)),
|
|
451
|
-
{
|
|
452
|
-
message: "Endpoint name must be unique"
|
|
453
|
-
}
|
|
454
|
-
),
|
|
455
|
-
resource: a(),
|
|
456
|
-
options: rt
|
|
457
|
-
}), 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({
|
|
458
|
-
permissions: c({
|
|
459
|
-
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"), {
|
|
460
|
-
message: "'basic:read' is required in scopes"
|
|
461
|
-
})
|
|
462
|
-
}).optional()
|
|
463
|
-
}).optional(), K = c({
|
|
464
|
-
key: a(),
|
|
465
|
-
type: a(),
|
|
466
|
-
label: a()
|
|
467
|
-
}), ct = c({
|
|
468
|
-
id: a(),
|
|
469
|
-
title: a(),
|
|
470
|
-
iconUrl: a(),
|
|
471
|
-
returns: l(K),
|
|
472
|
-
version: te().int().positive(),
|
|
473
|
-
externalId: a(),
|
|
474
|
-
parameters: l(K)
|
|
475
|
-
}), lt = l(ct).optional(), pt = c({
|
|
476
|
-
appId: a().length(25),
|
|
477
|
-
appType: et,
|
|
478
|
-
experimental: Se().optional(),
|
|
479
|
-
secrets: nt.optional(),
|
|
480
|
-
network: c({
|
|
481
|
-
allowedHosts: l(
|
|
482
|
-
a().refine((e) => st.test(e), {
|
|
483
|
-
message: "Invalid host format"
|
|
484
|
-
})
|
|
485
|
-
).optional(),
|
|
486
|
-
endpoints: l(ot).optional()
|
|
487
|
-
}).optional(),
|
|
488
|
-
permissionsSchema: it,
|
|
489
|
-
automation: c({
|
|
490
|
-
actions: lt
|
|
491
|
-
}).optional(),
|
|
492
|
-
surfaces: c({
|
|
493
|
-
guideline: c({
|
|
494
|
-
pageAction: c({
|
|
495
|
-
title: a().min(2).max(28)
|
|
496
|
-
}).optional(),
|
|
497
|
-
assetViewer: c({
|
|
498
|
-
title: a().min(2).max(28),
|
|
499
|
-
type: l(P),
|
|
500
|
-
filenameExtension: l(
|
|
501
|
-
a().refine((e) => !g.includes(e), {
|
|
502
|
-
message: v("guideline")
|
|
503
|
-
})
|
|
504
|
-
)
|
|
505
|
-
}).optional()
|
|
506
|
-
}).optional(),
|
|
507
|
-
mediaLibrary: c({
|
|
508
|
-
assetBulkActions: c({
|
|
509
|
-
title: a().min(2).max(28),
|
|
510
|
-
filenameExtensions: l(
|
|
511
|
-
a().refine((e) => !g.includes(e), {
|
|
512
|
-
message: v("mediaLibrary")
|
|
513
|
-
})
|
|
514
|
-
)
|
|
515
|
-
}).optional(),
|
|
516
|
-
assetAction: c({
|
|
517
|
-
title: a().min(2).max(28),
|
|
518
|
-
type: l(P),
|
|
519
|
-
filenameExtension: l(
|
|
520
|
-
a().refine((e) => !g.includes(e), {
|
|
521
|
-
message: v("mediaLibrary")
|
|
522
|
-
})
|
|
523
|
-
)
|
|
524
|
-
}).optional(),
|
|
525
|
-
assetCreation: T
|
|
526
|
-
}).optional(),
|
|
527
|
-
iconLibrary: c({
|
|
528
|
-
assetBulkActions: c({
|
|
529
|
-
title: a().min(2).max(28),
|
|
530
|
-
filenameExtensions: l(H)
|
|
531
|
-
}).optional(),
|
|
532
|
-
assetAction: c({
|
|
533
|
-
title: a().min(2).max(28),
|
|
534
|
-
type: l(z),
|
|
535
|
-
filenameExtension: l(H)
|
|
536
|
-
}).optional(),
|
|
537
|
-
assetCreation: T
|
|
538
|
-
}).optional(),
|
|
539
|
-
logoLibrary: c({
|
|
540
|
-
assetBulkActions: c({
|
|
541
|
-
title: a().min(2).max(28),
|
|
542
|
-
filenameExtensions: l(Y)
|
|
543
|
-
}).optional(),
|
|
544
|
-
assetAction: c({
|
|
545
|
-
title: a().min(2).max(28),
|
|
546
|
-
type: l(z),
|
|
547
|
-
filenameExtension: l(Y)
|
|
548
|
-
}).optional(),
|
|
549
|
-
assetCreation: T
|
|
550
|
-
}).optional(),
|
|
551
|
-
documentLibrary: c({
|
|
552
|
-
assetBulkActions: c({
|
|
553
|
-
title: a().min(2).max(28),
|
|
554
|
-
filenameExtensions: l(
|
|
555
|
-
a().refine((e) => !g.includes(e), {
|
|
556
|
-
message: v("documentLibrary")
|
|
557
|
-
})
|
|
558
|
-
)
|
|
559
|
-
}).optional(),
|
|
560
|
-
assetAction: c({
|
|
561
|
-
title: a().min(2).max(28),
|
|
562
|
-
type: l(P),
|
|
563
|
-
filenameExtension: l(
|
|
564
|
-
a().refine((e) => !g.includes(e), {
|
|
565
|
-
message: v("documentLibrary")
|
|
566
|
-
})
|
|
567
|
-
)
|
|
568
|
-
}).optional(),
|
|
569
|
-
assetCreation: T
|
|
570
|
-
}).optional(),
|
|
571
|
-
workspace: c({
|
|
572
|
-
assetBulkActions: c({
|
|
573
|
-
title: a().min(2).max(28),
|
|
574
|
-
filenameExtensions: l(
|
|
575
|
-
a().refine((e) => !g.includes(e), {
|
|
576
|
-
message: v("workspaceProject")
|
|
577
|
-
})
|
|
578
|
-
)
|
|
579
|
-
}).optional(),
|
|
580
|
-
assetAction: c({
|
|
581
|
-
title: a().min(2).max(28),
|
|
582
|
-
type: l(P),
|
|
583
|
-
filenameExtension: l(
|
|
584
|
-
a().refine((e) => !g.includes(e), {
|
|
585
|
-
message: v("workspaceProject")
|
|
586
|
-
})
|
|
587
|
-
)
|
|
588
|
-
}).optional(),
|
|
589
|
-
assetCreation: T
|
|
590
|
-
}).optional()
|
|
591
|
-
}).optional(),
|
|
592
|
-
metadata: c({
|
|
593
|
-
version: te().int()
|
|
594
|
-
})
|
|
595
|
-
}), dt = (e, t) => {
|
|
596
|
-
const n = t.safeParse(e);
|
|
597
|
-
if (!n.success)
|
|
598
|
-
throw new Error(n.error.message);
|
|
599
|
-
return n.data;
|
|
600
|
-
}, G = async (e, t) => {
|
|
601
|
-
const n = await E(`${E.convertPathToPattern(e)}/**`, { ignore: t, dot: !0 });
|
|
602
|
-
return n.map((o) => o.replace(`${e}/`, "")).reduce((o, i, p) => (o[`/${i}`] = ze(n[p]), o), {});
|
|
603
|
-
}, mt = ["**/*.*.map"], ft = [
|
|
604
|
-
".git",
|
|
605
|
-
"node_modules",
|
|
606
|
-
"dist",
|
|
607
|
-
".vscode",
|
|
608
|
-
".idea",
|
|
609
|
-
".eslintignore",
|
|
610
|
-
".prettierignore",
|
|
611
|
-
"README.md",
|
|
612
|
-
".DS_Store",
|
|
613
|
-
"**/*.graphql"
|
|
614
|
-
], D = async (e, t, { dryRun: n = !1, noVerify: r = !1, openInBrowser: o = !1, token: i, instance: p }, u) => {
|
|
615
|
-
try {
|
|
616
|
-
let h;
|
|
617
|
-
const S = p || k.get("instanceUrl"), J = i || k.get("tokens.access_token");
|
|
618
|
-
if ((!J || !S) && (s.error(
|
|
619
|
-
`You are currently not logged in. You can use the command ${b.bold(
|
|
620
|
-
"frontify-cli login"
|
|
621
|
-
)} to log in, or pass --token=<token> --instance=<instance> to the deploy command.`
|
|
622
|
-
), process.exit(-1)), n || (h = await oe(S, i), h && s.info(`You are logged in as ${h.name} (${S}).`)), h || n) {
|
|
623
|
-
n && s.info(b.blue("Dry run: enabled"));
|
|
624
|
-
const y = process.cwd(), R = $(m(y, "manifest.json")), { appId: _ } = R.appType === "platform-app" ? dt(R, pt) : R;
|
|
625
|
-
r || (s.info("Performing type checks..."), await M("npx tsc --noEmit"), s.info("Performing eslint checks..."), await M("npx eslint src"));
|
|
626
|
-
try {
|
|
627
|
-
await u({ projectPath: y, entryFile: e, outputName: _ });
|
|
628
|
-
} catch (d) {
|
|
629
|
-
s.error(d), process.exit(-1);
|
|
630
|
-
}
|
|
631
|
-
const pe = mt.map(
|
|
632
|
-
(d) => E.convertPathToPattern(y + d)
|
|
633
|
-
), de = [...He(m(y, ".gitignore")).filter(
|
|
634
|
-
(d) => d !== "manifest.json"
|
|
635
|
-
), ...ft].map((d) => d.includes("*") ? `${y}/${d}` : E.convertPathToPattern(`${y}/${d}`)), me = {
|
|
636
|
-
build_files: await G(
|
|
637
|
-
E.convertPathToPattern(`${y}/${t}`),
|
|
638
|
-
pe
|
|
639
|
-
),
|
|
640
|
-
source_files: await G(E.convertPathToPattern(y), de)
|
|
641
|
-
};
|
|
642
|
-
if (n)
|
|
643
|
-
s.success("The command has been executed without any issue."), process.exit(0);
|
|
644
|
-
else {
|
|
645
|
-
s.info("Sending the files to Frontify Marketplace...");
|
|
646
|
-
const d = new V(S);
|
|
647
|
-
try {
|
|
648
|
-
await d.put(`/api/marketplace/app/${_}`, me, {
|
|
649
|
-
headers: { Authorization: `Bearer ${J}` }
|
|
650
|
-
}), s.success("The new version has been pushed."), o && (s.info("Opening the Frontify Marketplace page..."), await Q(`https://${S}/marketplace/apps/${_}`));
|
|
651
|
-
} catch (fe) {
|
|
652
|
-
s.error("An error occured while deploying:", fe.responseBody.error), process.exit(-1);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
} catch (h) {
|
|
657
|
-
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);
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
class ut {
|
|
661
|
-
constructor(t, n = 5600) {
|
|
662
|
-
this.fastifyServer = Pe(), this.instanceUrl = t, this.port = n, this.httpClient = new V(t);
|
|
663
|
-
}
|
|
664
|
-
serveCallbackServer() {
|
|
665
|
-
this.registerPlugins(), this.registerRoutes(), this.fastifyServer.listen({ port: this.port });
|
|
666
|
-
}
|
|
667
|
-
registerRoutes() {
|
|
668
|
-
this.fastifyServer.get("/oauth", async (t, n) => {
|
|
669
|
-
s.info("Access granted, getting access token..."), n.send("You can close this window.");
|
|
670
|
-
const r = await this.getOauthCredentialDetails(t.query.code);
|
|
671
|
-
s.info("Tokens received, storing tokens..."), k.set("tokens", r), k.set("instanceUrl", this.instanceUrl);
|
|
672
|
-
const o = await oe(this.instanceUrl);
|
|
673
|
-
o && s.success(`Welcome back ${o.name} (${this.instanceUrl})!`), process.exit(0);
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
registerPlugins() {
|
|
677
|
-
this.fastifyServer.register(Te);
|
|
678
|
-
}
|
|
679
|
-
async storeRandomCodeChallenge() {
|
|
680
|
-
try {
|
|
681
|
-
const t = await this.httpClient.get(
|
|
682
|
-
"/api/oauth/random"
|
|
683
|
-
);
|
|
684
|
-
this.randomChallenge = t.data;
|
|
685
|
-
} catch (t) {
|
|
686
|
-
const n = t instanceof Error ? t.message : String(t);
|
|
687
|
-
throw new Error(`An error occurred while getting the random challenge: ${n}`);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
getLoginUrl() {
|
|
691
|
-
if (!this.randomChallenge)
|
|
692
|
-
throw new Error("Random challenge needs to be defined.");
|
|
693
|
-
const t = [
|
|
694
|
-
"response_type=code",
|
|
695
|
-
"client_id=block-cli",
|
|
696
|
-
"redirect_uri=http://localhost:5600/oauth",
|
|
697
|
-
"scope=basic:read%2Bblocks:read%2Bblocks:write",
|
|
698
|
-
`code_challenge=${this.randomChallenge.sha256}`,
|
|
699
|
-
"code_challenge_method=S256"
|
|
700
|
-
].join("&");
|
|
701
|
-
return `https://${this.instanceUrl}/api/oauth/authorize?${t}`;
|
|
702
|
-
}
|
|
703
|
-
async getOauthCredentialDetails(t) {
|
|
704
|
-
if (!this.randomChallenge)
|
|
705
|
-
throw new Error("Random challenge needs to be defined.");
|
|
706
|
-
try {
|
|
707
|
-
return await this.httpClient.post("/api/oauth/accesstoken", {
|
|
708
|
-
grant_type: "authorization_code",
|
|
709
|
-
client_id: "block-cli",
|
|
710
|
-
redirect_uri: "http://localhost:5600/oauth",
|
|
711
|
-
scope: "basic:read+blocks:read+blocks:write",
|
|
712
|
-
code_verifier: this.randomChallenge.secret,
|
|
713
|
-
code: t
|
|
714
|
-
});
|
|
715
|
-
} catch (n) {
|
|
716
|
-
const r = n instanceof Error ? n.message : String(n);
|
|
717
|
-
throw new Error(`An error occurred while getting tokens: ${r}`);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
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
|
+
};
|
|
720
348
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
},
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
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);
|
|
909
863
|
});
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
default: m("src", "index.tsx")
|
|
914
|
-
}).option("--port <port>", "[number] specify port", {
|
|
915
|
-
default: process.env.PORT || 5600
|
|
916
|
-
}).option("--allowExternal, --allow-external", "[boolean] allow external IPs to access the server", {
|
|
917
|
-
default: !1
|
|
918
|
-
}).action(async (t) => {
|
|
919
|
-
await ce(t.entryPath, t.port, t.allowExternal);
|
|
920
|
-
});
|
|
921
|
-
f.command("serve", "serve the app locally").alias("dev").option("-e, --entryPath, --entry-path <entryPath>", "[string] path to the entry file", {
|
|
922
|
-
default: m("src", "index.ts")
|
|
923
|
-
}).option("--port <port>", "[number] specify port", {
|
|
924
|
-
default: process.env.PORT || 5600
|
|
925
|
-
}).option("--allowExternal, --allow-external", "[boolean] allow external IPs to access the server", {
|
|
926
|
-
default: !1
|
|
927
|
-
}).option("--appType <appType>, --app-type", "[string] specify app type. Overrides manifest values").action(async (e) => {
|
|
928
|
-
const t = $(m(process.cwd(), "manifest.json")), n = e.appType || t.appType;
|
|
929
|
-
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);
|
|
930
867
|
});
|
|
931
|
-
for (
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
dryRun: t.dryRun,
|
|
938
|
-
noVerify: t.noVerify,
|
|
939
|
-
openInBrowser: t.open
|
|
940
|
-
},
|
|
941
|
-
e === "theme" ? ie : se
|
|
942
|
-
);
|
|
943
|
-
});
|
|
944
|
-
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) => {
|
|
945
|
-
const t = $(m(process.cwd(), "manifest.json")), n = e.appType || t.appType;
|
|
946
|
-
n === "platform-app" ? await D(
|
|
947
|
-
e.entryPath,
|
|
948
|
-
e.outDir,
|
|
949
|
-
{
|
|
950
|
-
dryRun: e.dryRun,
|
|
951
|
-
noVerify: e.noVerify,
|
|
952
|
-
openInBrowser: e.open,
|
|
953
|
-
instance: e.instance,
|
|
954
|
-
token: e.token
|
|
955
|
-
},
|
|
956
|
-
Xe
|
|
957
|
-
) : n === "theme" ? await D(
|
|
958
|
-
e.entryPath,
|
|
959
|
-
e.outDir,
|
|
960
|
-
{
|
|
961
|
-
dryRun: e.dryRun,
|
|
962
|
-
noVerify: e.noVerify,
|
|
963
|
-
openInBrowser: e.open,
|
|
964
|
-
instance: e.instance,
|
|
965
|
-
token: e.token
|
|
966
|
-
},
|
|
967
|
-
ie
|
|
968
|
-
) : await D(
|
|
969
|
-
e.entryPath,
|
|
970
|
-
e.outDir,
|
|
971
|
-
{
|
|
972
|
-
dryRun: e.dryRun,
|
|
973
|
-
noVerify: e.noVerify,
|
|
974
|
-
openInBrowser: e.open,
|
|
975
|
-
instance: e.instance,
|
|
976
|
-
token: e.token
|
|
977
|
-
},
|
|
978
|
-
se
|
|
979
|
-
);
|
|
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);
|
|
980
874
|
});
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
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);
|
|
1011
938
|
});
|
|
1012
|
-
for (
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
const t = e.findIndex((n) => n === "block" || n === "theme");
|
|
1021
|
-
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;
|
|
1022
|
-
};
|
|
1023
|
-
f.parse(Et(process.argv));
|
|
1024
|
-
//# 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
|