@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/README.md +1 -1
- package/dist/index.mjs +934 -954
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,966 +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
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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
|
-
|
|
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
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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 (
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
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
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
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 (
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
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
|