attio 0.0.1-experimental.20241226 → 0.0.1-experimental.20250108
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/lib/api/create-version.js +2 -2
- package/lib/attio-logo.js +24 -0
- package/lib/attio.js +17 -8
- package/lib/commands/build.js +18 -35
- package/lib/commands/connection/add.js +51 -168
- package/lib/commands/connection/index.js +9 -1
- package/lib/commands/connection/list.js +17 -47
- package/lib/commands/connection/remove.js +17 -65
- package/lib/commands/create.js +27 -126
- package/lib/commands/dev.js +17 -106
- package/lib/commands/version/create.js +17 -68
- package/lib/commands/version/index.js +11 -1
- package/lib/commands/version/invite.js +40 -84
- package/lib/commands/version/list.js +18 -40
- package/lib/commands/version/publish.js +40 -64
- package/lib/machines/actions.js +7 -0
- package/lib/machines/actors.js +26 -1
- package/lib/machines/add-connection-machine.js +169 -201
- package/lib/machines/build-machine.js +35 -4
- package/lib/machines/create-machine.js +95 -70
- package/lib/machines/create-version-machine.js +152 -7
- package/lib/machines/dev-machine.js +173 -53
- package/lib/machines/generate-invite-machine.js +64 -10
- package/lib/machines/list-connections-machine.js +57 -2
- package/lib/machines/list-versions-machine.js +47 -14
- package/lib/machines/publish-version-machine.js +45 -16
- package/lib/machines/remove-connection-machine.js +64 -17
- package/lib/machines/ts-machine.js +4 -1
- package/lib/server/attio-fetch.d.ts +3 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util/clear-terminal.js +4 -0
- package/lib/util/load-developer-config.js +2 -2
- package/lib/util/print-install-instructions.js +32 -0
- package/lib/util/print-message.js +9 -0
- package/lib/util/set-terminal-title.js +8 -0
- package/lib/util/text-gradient.js +28 -0
- package/lib/util/typescript.js +25 -0
- package/package.json +13 -12
- package/lib/components/BuildError.js +0 -46
- package/lib/components/BuildLog.js +0 -6
- package/lib/components/CodeGenErrors.js +0 -22
- package/lib/components/Disclaimer.js +0 -9
- package/lib/components/InitialInstructions.js +0 -69
- package/lib/components/Log.js +0 -69
- package/lib/components/Logo.js +0 -10
- package/lib/components/MultiSelect.js +0 -65
- package/lib/components/ScrollBox.js +0 -87
- package/lib/components/ScrollBox.store.js +0 -36
- package/lib/components/ScrollBox.util.js +0 -27
- package/lib/components/Select.js +0 -6
- package/lib/components/Table.js +0 -33
- package/lib/components/TypeScriptErrors.js +0 -38
- package/lib/hooks/useFullScreen.js +0 -22
- package/lib/hooks/useTerminalTitle.js +0 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync } from "fs";
|
|
2
|
+
import Spinner from "tiny-spinner";
|
|
2
3
|
import path, { join } from "path";
|
|
3
4
|
import { fileURLToPath } from "url";
|
|
4
5
|
import { assign, setup, fromCallback } from "xstate";
|
|
@@ -9,13 +10,14 @@ import { createDirectory } from "../util/create-directory.js";
|
|
|
9
10
|
import { loadDeveloperConfig } from "../util/load-developer-config.js";
|
|
10
11
|
import { slugifyExtension } from "../util/slugify-extension.js";
|
|
11
12
|
import { canWrite, isValidSlug } from "../util/validate-slug.js";
|
|
13
|
+
import { ask, askWithChoices } from "./actors.js";
|
|
14
|
+
import { showError, printLogo } from "./actions.js";
|
|
15
|
+
import chalk from "chalk";
|
|
16
|
+
import boxen from "boxen";
|
|
17
|
+
import { printInstallInstructions } from "../util/print-install-instructions.js";
|
|
12
18
|
export const languages = [
|
|
13
|
-
{
|
|
14
|
-
{
|
|
15
|
-
];
|
|
16
|
-
export const outlets = [
|
|
17
|
-
{ value: "tool", label: "Workflow Tool" },
|
|
18
|
-
{ value: "action", label: "Action Button" },
|
|
19
|
+
{ name: "TypeScript – recommended!", value: "typescript" },
|
|
20
|
+
{ name: "JavaScript", value: "javascript" },
|
|
19
21
|
];
|
|
20
22
|
export const createMachine = setup({
|
|
21
23
|
types: {
|
|
@@ -24,6 +26,8 @@ export const createMachine = setup({
|
|
|
24
26
|
input: {},
|
|
25
27
|
},
|
|
26
28
|
actors: {
|
|
29
|
+
ask,
|
|
30
|
+
askWithChoices,
|
|
27
31
|
createProject: fromCallback(({ sendBack, input }) => {
|
|
28
32
|
const create = async () => {
|
|
29
33
|
try {
|
|
@@ -49,6 +53,8 @@ export const createMachine = setup({
|
|
|
49
53
|
}),
|
|
50
54
|
createApp: fromCallback(({ sendBack, input: { appSlug, token, developerSlug, title } }) => {
|
|
51
55
|
const create = async () => {
|
|
56
|
+
const spinner = new Spinner();
|
|
57
|
+
spinner.start(`Creating app "${title}"...`);
|
|
52
58
|
try {
|
|
53
59
|
const result = await createApp({
|
|
54
60
|
token,
|
|
@@ -56,9 +62,11 @@ export const createMachine = setup({
|
|
|
56
62
|
appSlug: appSlug,
|
|
57
63
|
title,
|
|
58
64
|
});
|
|
65
|
+
spinner.success(`"${title}" created!`);
|
|
59
66
|
sendBack({ type: "App Created", appId: result.app_id });
|
|
60
67
|
}
|
|
61
68
|
catch (error) {
|
|
69
|
+
spinner.error(error.message);
|
|
62
70
|
sendBack({ type: "Error", error: error.message });
|
|
63
71
|
}
|
|
64
72
|
};
|
|
@@ -80,13 +88,17 @@ export const createMachine = setup({
|
|
|
80
88
|
load();
|
|
81
89
|
}),
|
|
82
90
|
validateSlug: fromCallback(({ sendBack, input: { appSlug, token, developerSlug } }) => {
|
|
91
|
+
const spinner = new Spinner();
|
|
92
|
+
spinner.start("Checking if slug is valid...");
|
|
83
93
|
if (!isValidSlug(appSlug)) {
|
|
94
|
+
spinner.error("Invalid slug");
|
|
84
95
|
sendBack({
|
|
85
96
|
type: "Invalid Slug",
|
|
86
97
|
error: "Slug contains invalid characters. Must be lowercase letters or hyphens only.",
|
|
87
98
|
});
|
|
88
99
|
}
|
|
89
100
|
if (existsSync(join(process.cwd(), appSlug))) {
|
|
101
|
+
spinner.error("Invalid slug");
|
|
90
102
|
sendBack({
|
|
91
103
|
type: "Invalid Slug",
|
|
92
104
|
error: `Directory "${appSlug}" already exists`,
|
|
@@ -94,6 +106,7 @@ export const createMachine = setup({
|
|
|
94
106
|
return;
|
|
95
107
|
}
|
|
96
108
|
if (!canWrite(".")) {
|
|
109
|
+
spinner.error("Fatal Error");
|
|
97
110
|
sendBack({
|
|
98
111
|
type: "Fatal Error",
|
|
99
112
|
error: "Write access denied to current directory",
|
|
@@ -101,29 +114,48 @@ export const createMachine = setup({
|
|
|
101
114
|
return;
|
|
102
115
|
}
|
|
103
116
|
isAppSlugValid({ token, developerSlug, appSlug: appSlug })
|
|
104
|
-
.then((valid) =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
type: "
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
.then((valid) => {
|
|
118
|
+
spinner.success("Valid slug");
|
|
119
|
+
sendBack(valid
|
|
120
|
+
? { type: "Valid Slug" }
|
|
121
|
+
: {
|
|
122
|
+
type: "Invalid Slug",
|
|
123
|
+
error: "An app already exists with this slug",
|
|
124
|
+
});
|
|
125
|
+
})
|
|
110
126
|
.catch((error) => {
|
|
127
|
+
spinner.error("Fatal Error");
|
|
111
128
|
sendBack({ type: "Fatal Error", error: error.message });
|
|
112
129
|
});
|
|
113
130
|
}),
|
|
114
131
|
},
|
|
115
132
|
actions: {
|
|
133
|
+
printLogo,
|
|
116
134
|
clearError: assign({
|
|
117
135
|
error: () => undefined,
|
|
118
136
|
}),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
showError,
|
|
138
|
+
showConfigInstructions: ({ context: { configError } }) => {
|
|
139
|
+
printInstallInstructions(configError);
|
|
140
|
+
},
|
|
141
|
+
showInstructions: ({ context: { appSlug, title } }) => {
|
|
142
|
+
const commands = `cd ${appSlug}\nnpm install\nnpm run dev`;
|
|
143
|
+
process.stdout.write("\n" +
|
|
144
|
+
chalk.green(`SUCCESS!! 🎉 Your extension "${title}" has been created.`) +
|
|
145
|
+
"\n");
|
|
146
|
+
process.stdout.write("\nTo get started, run:\n");
|
|
147
|
+
process.stdout.write(boxen(commands, {
|
|
148
|
+
padding: 1,
|
|
149
|
+
margin: 1,
|
|
150
|
+
borderStyle: "round",
|
|
151
|
+
}) + "\n");
|
|
152
|
+
process.stdout.write(`(${chalk.yellow("yarn")}, ${chalk.yellow("pnpm")}, and ${chalk.yellow("bun")} also work!)\n`);
|
|
153
|
+
},
|
|
122
154
|
setLanguage: assign({
|
|
123
|
-
language: (_, params) => params.
|
|
155
|
+
language: (_, params) => params.output,
|
|
124
156
|
}),
|
|
125
157
|
setTitle: assign({
|
|
126
|
-
title: (_, params) => params.
|
|
158
|
+
title: (_, params) => params.output,
|
|
127
159
|
}),
|
|
128
160
|
setConfig: assign({
|
|
129
161
|
token: (_, params) => params.token,
|
|
@@ -136,10 +168,7 @@ export const createMachine = setup({
|
|
|
136
168
|
appId: (_, params) => params.appId,
|
|
137
169
|
}),
|
|
138
170
|
setSlug: assign({
|
|
139
|
-
appSlug: (_, params) => slugifyExtension(params.
|
|
140
|
-
}),
|
|
141
|
-
setOutlets: assign({
|
|
142
|
-
outlets: (_, params) => params.outlets,
|
|
171
|
+
appSlug: (_, params) => slugifyExtension(params.output, false),
|
|
143
172
|
}),
|
|
144
173
|
slugifyTitle: assign({
|
|
145
174
|
appSlug: (_, params) => slugifyExtension(params.title),
|
|
@@ -149,7 +178,6 @@ export const createMachine = setup({
|
|
|
149
178
|
"have title": (_, params) => Boolean(params.title.trim()),
|
|
150
179
|
"have slug": (_, params) => Boolean(params.slug.trim()),
|
|
151
180
|
"have language": (_, params) => Boolean(params.language),
|
|
152
|
-
"have outlets": (_, params) => Boolean(params.outlets?.length),
|
|
153
181
|
},
|
|
154
182
|
}).createMachine({
|
|
155
183
|
context: ({ input }) => ({
|
|
@@ -178,33 +206,34 @@ export const createMachine = setup({
|
|
|
178
206
|
],
|
|
179
207
|
},
|
|
180
208
|
"Ask for title": {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
209
|
+
invoke: {
|
|
210
|
+
src: "ask",
|
|
211
|
+
input: {
|
|
212
|
+
message: 'What would you like to call your new app? (in "Title Case")',
|
|
213
|
+
required: true,
|
|
185
214
|
},
|
|
186
|
-
|
|
215
|
+
onDone: {
|
|
187
216
|
target: "Validate Slug From Title",
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
217
|
+
actions: [
|
|
218
|
+
{ type: "setTitle", params: ({ event }) => event },
|
|
219
|
+
{ type: "slugifyTitle", params: ({ context }) => context },
|
|
220
|
+
],
|
|
191
221
|
},
|
|
192
222
|
},
|
|
193
223
|
},
|
|
194
224
|
"Ask for language": {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
225
|
+
invoke: {
|
|
226
|
+
src: "askWithChoices",
|
|
227
|
+
input: {
|
|
228
|
+
message: "What language would you like to use?",
|
|
229
|
+
choices: languages,
|
|
200
230
|
},
|
|
201
|
-
|
|
202
|
-
},
|
|
203
|
-
"Ask for outlets": {
|
|
204
|
-
on: {
|
|
205
|
-
"Choose Outlets": {
|
|
231
|
+
onDone: {
|
|
206
232
|
target: "Create App",
|
|
207
|
-
actions: {
|
|
233
|
+
actions: {
|
|
234
|
+
type: "setLanguage",
|
|
235
|
+
params: ({ event }) => event,
|
|
236
|
+
},
|
|
208
237
|
reenter: true,
|
|
209
238
|
},
|
|
210
239
|
},
|
|
@@ -213,7 +242,7 @@ export const createMachine = setup({
|
|
|
213
242
|
on: {
|
|
214
243
|
Error: {
|
|
215
244
|
target: "Error",
|
|
216
|
-
actions: { type: "
|
|
245
|
+
actions: { type: "showError", params: ({ event }) => event },
|
|
217
246
|
},
|
|
218
247
|
Success: {
|
|
219
248
|
target: "Success",
|
|
@@ -237,11 +266,12 @@ export const createMachine = setup({
|
|
|
237
266
|
"Success": {
|
|
238
267
|
type: "final",
|
|
239
268
|
description: `🎉🎉🎉🎉🎉🎉`,
|
|
269
|
+
entry: "showInstructions",
|
|
240
270
|
},
|
|
241
271
|
"Do we need language?": {
|
|
242
272
|
always: [
|
|
243
273
|
{
|
|
244
|
-
target: "
|
|
274
|
+
target: "Create App",
|
|
245
275
|
guard: { type: "have language", params: ({ context }) => context },
|
|
246
276
|
reenter: true,
|
|
247
277
|
description: `language may have been provided by CLI option`,
|
|
@@ -249,30 +279,18 @@ export const createMachine = setup({
|
|
|
249
279
|
"Ask for language",
|
|
250
280
|
],
|
|
251
281
|
},
|
|
252
|
-
"
|
|
253
|
-
|
|
254
|
-
{
|
|
255
|
-
target: "Create App",
|
|
256
|
-
guard: { type: "have outlets", params: ({ context }) => context },
|
|
257
|
-
description: `outlets may have been provided by CLI option`,
|
|
258
|
-
reenter: true,
|
|
259
|
-
},
|
|
282
|
+
"Validate Slug": {
|
|
283
|
+
invoke: [
|
|
260
284
|
{
|
|
261
|
-
|
|
262
|
-
|
|
285
|
+
src: "validateSlug",
|
|
286
|
+
input: ({ context }) => context,
|
|
263
287
|
},
|
|
264
288
|
],
|
|
265
|
-
},
|
|
266
|
-
"Validate Slug": {
|
|
267
|
-
invoke: {
|
|
268
|
-
src: "validateSlug",
|
|
269
|
-
input: ({ context }) => context,
|
|
270
|
-
},
|
|
271
289
|
on: {
|
|
272
290
|
"Invalid Slug": {
|
|
273
291
|
target: "Ask for slug",
|
|
274
292
|
actions: {
|
|
275
|
-
type: "
|
|
293
|
+
type: "showError",
|
|
276
294
|
params: ({ event }) => event,
|
|
277
295
|
},
|
|
278
296
|
reenter: true,
|
|
@@ -301,6 +319,7 @@ export const createMachine = setup({
|
|
|
301
319
|
},
|
|
302
320
|
"Show config instructions": {
|
|
303
321
|
type: "final",
|
|
322
|
+
entry: "showConfigInstructions",
|
|
304
323
|
},
|
|
305
324
|
"Create App": {
|
|
306
325
|
invoke: {
|
|
@@ -314,17 +333,22 @@ export const createMachine = setup({
|
|
|
314
333
|
},
|
|
315
334
|
"Error": {
|
|
316
335
|
target: "Error",
|
|
317
|
-
actions: { type: "
|
|
336
|
+
actions: { type: "showError", params: ({ event }) => event },
|
|
318
337
|
},
|
|
319
338
|
},
|
|
320
339
|
},
|
|
321
340
|
"Ask for slug": {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
341
|
+
invoke: {
|
|
342
|
+
src: "ask",
|
|
343
|
+
input: ({ context }) => ({
|
|
344
|
+
message: "Please provide a slug for your extension:",
|
|
345
|
+
default: context.appSlug,
|
|
346
|
+
required: true,
|
|
347
|
+
}),
|
|
348
|
+
onDone: {
|
|
349
|
+
target: "Validate Slug",
|
|
350
|
+
actions: { type: "setSlug", params: ({ event }) => event },
|
|
326
351
|
},
|
|
327
|
-
"Submit": "Validate Slug",
|
|
328
352
|
},
|
|
329
353
|
},
|
|
330
354
|
"Validate Slug From Title": {
|
|
@@ -336,7 +360,7 @@ export const createMachine = setup({
|
|
|
336
360
|
"Invalid Slug": {
|
|
337
361
|
target: "Ask for slug",
|
|
338
362
|
actions: {
|
|
339
|
-
type: "
|
|
363
|
+
type: "showError",
|
|
340
364
|
params: ({ event }) => event,
|
|
341
365
|
},
|
|
342
366
|
},
|
|
@@ -347,7 +371,7 @@ export const createMachine = setup({
|
|
|
347
371
|
"Fatal Error": {
|
|
348
372
|
target: "Error",
|
|
349
373
|
actions: {
|
|
350
|
-
type: "
|
|
374
|
+
type: "showError",
|
|
351
375
|
params: ({ event }) => event,
|
|
352
376
|
},
|
|
353
377
|
},
|
|
@@ -362,7 +386,7 @@ export const createMachine = setup({
|
|
|
362
386
|
"Invalid Slug": {
|
|
363
387
|
target: "Ask for slug",
|
|
364
388
|
actions: {
|
|
365
|
-
type: "
|
|
389
|
+
type: "showError",
|
|
366
390
|
params: ({ event }) => event,
|
|
367
391
|
},
|
|
368
392
|
},
|
|
@@ -373,7 +397,7 @@ export const createMachine = setup({
|
|
|
373
397
|
"Fatal Error": {
|
|
374
398
|
target: "Error",
|
|
375
399
|
actions: {
|
|
376
|
-
type: "
|
|
400
|
+
type: "showError",
|
|
377
401
|
params: ({ event }) => event,
|
|
378
402
|
},
|
|
379
403
|
},
|
|
@@ -381,4 +405,5 @@ export const createMachine = setup({
|
|
|
381
405
|
},
|
|
382
406
|
},
|
|
383
407
|
initial: "Load Config",
|
|
408
|
+
entry: "printLogo",
|
|
384
409
|
});
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { assign, setup, fromCallback } from "xstate";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import { completeProdBundleUpload } from "../api/complete-prod-bundle-upload.js";
|
|
3
4
|
import { createVersion } from "../api/create-version.js";
|
|
4
5
|
import { emptyConfig } from "../schema.js";
|
|
5
6
|
import { updateAppConfig } from "../util/app-config.js";
|
|
6
|
-
import { loadAppConfig, loadDeveloperConfig } from "./actors.js";
|
|
7
|
+
import { askWithTypedChoices, loadAppConfig, loadDeveloperConfig, confirm, fetchVersions, } from "./actors.js";
|
|
7
8
|
import { jsMachine } from "./js-machine.js";
|
|
9
|
+
import { printInstallInstructions } from "../util/print-install-instructions.js";
|
|
10
|
+
import { showError, printLogo } from "./actions.js";
|
|
11
|
+
import Spinner from "tiny-spinner";
|
|
8
12
|
export const connectionTypes = [
|
|
9
13
|
{ value: "secret", label: "Secret" },
|
|
10
14
|
{ value: "oauth2-code", label: "OAuth2" },
|
|
@@ -13,25 +17,43 @@ export const audiences = [
|
|
|
13
17
|
{ value: "workspace", label: "Workspace" },
|
|
14
18
|
{ value: "workspace-member", label: "Workspace Member" },
|
|
15
19
|
];
|
|
20
|
+
const bundlingSpinner = new Spinner();
|
|
16
21
|
export const createVersionMachine = setup({
|
|
17
22
|
types: {
|
|
18
23
|
context: {},
|
|
19
24
|
events: {},
|
|
20
25
|
children: {},
|
|
21
26
|
},
|
|
27
|
+
guards: {
|
|
28
|
+
"confirmed": (_, params) => params.output,
|
|
29
|
+
"is major": (_, params) => params.output === "major",
|
|
30
|
+
"no major version": (_, params) => params.versions.length === 0,
|
|
31
|
+
},
|
|
22
32
|
actors: {
|
|
33
|
+
confirm,
|
|
34
|
+
fetchVersions,
|
|
35
|
+
askForUpgradeType: askWithTypedChoices(),
|
|
23
36
|
javascript: jsMachine,
|
|
24
|
-
createVersion: fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, }, }) => {
|
|
37
|
+
createVersion: fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, upgradeType, }, }) => {
|
|
25
38
|
const add = async () => {
|
|
39
|
+
const spinner = new Spinner();
|
|
40
|
+
spinner.start("Creating version...");
|
|
26
41
|
try {
|
|
27
42
|
const res = await createVersion({
|
|
28
43
|
token,
|
|
29
44
|
devSlug,
|
|
30
45
|
appId: config.id,
|
|
46
|
+
major: upgradeType === "initial"
|
|
47
|
+
? 1
|
|
48
|
+
: upgradeType === "major"
|
|
49
|
+
? config.major + 1
|
|
50
|
+
: config.major,
|
|
31
51
|
});
|
|
52
|
+
spinner.success("Version created");
|
|
32
53
|
sendBack({ type: "Version Created", version: res });
|
|
33
54
|
}
|
|
34
55
|
catch (error) {
|
|
56
|
+
spinner.error("Error creating version");
|
|
35
57
|
sendBack({ type: "Error", error: error.message });
|
|
36
58
|
}
|
|
37
59
|
};
|
|
@@ -40,7 +62,9 @@ export const createVersionMachine = setup({
|
|
|
40
62
|
loadDeveloperConfig,
|
|
41
63
|
loadAppConfig,
|
|
42
64
|
upload: fromCallback(({ sendBack, input: { developer: { token, slug: developerSlug }, jsContents, version: { app_id: appId, client_bundle_upload_url, server_bundle_upload_url, major, minor, app_prod_version_bundle_id: bundleId, }, }, }) => {
|
|
65
|
+
const uploadSpinner = new Spinner();
|
|
43
66
|
const upload = async () => {
|
|
67
|
+
uploadSpinner.start("Uploading...");
|
|
44
68
|
const [clientBundle, serverBundle] = jsContents;
|
|
45
69
|
await Promise.all([
|
|
46
70
|
fetch(client_bundle_upload_url, {
|
|
@@ -48,7 +72,7 @@ export const createVersionMachine = setup({
|
|
|
48
72
|
body: clientBundle,
|
|
49
73
|
headers: {
|
|
50
74
|
"Content-Type": "text/javascript",
|
|
51
|
-
"Content-Length": String(clientBundle.length),
|
|
75
|
+
"Content-Length": String(Buffer.from(clientBundle).length),
|
|
52
76
|
},
|
|
53
77
|
}),
|
|
54
78
|
fetch(server_bundle_upload_url, {
|
|
@@ -56,10 +80,13 @@ export const createVersionMachine = setup({
|
|
|
56
80
|
body: serverBundle,
|
|
57
81
|
headers: {
|
|
58
82
|
"Content-Type": "text/javascript",
|
|
59
|
-
"Content-Length": String(serverBundle.length),
|
|
83
|
+
"Content-Length": String(Buffer.from(serverBundle).length),
|
|
60
84
|
},
|
|
61
85
|
}),
|
|
62
86
|
]);
|
|
87
|
+
uploadSpinner.success("Uploading complete");
|
|
88
|
+
const signSpinner = new Spinner();
|
|
89
|
+
signSpinner.start("Signing bundles...");
|
|
63
90
|
await completeProdBundleUpload({
|
|
64
91
|
token,
|
|
65
92
|
developerSlug,
|
|
@@ -68,23 +95,46 @@ export const createVersionMachine = setup({
|
|
|
68
95
|
minor,
|
|
69
96
|
bundleId,
|
|
70
97
|
});
|
|
98
|
+
signSpinner.success("Bundles signed");
|
|
71
99
|
updateAppConfig((config) => ({
|
|
72
100
|
...config,
|
|
73
101
|
major,
|
|
74
102
|
minor,
|
|
75
103
|
}));
|
|
104
|
+
process.stdout.write(`\nVersion ${chalk.green(`${major}.${minor}`)} created!\n\n`);
|
|
76
105
|
sendBack({ type: "Upload Complete" });
|
|
77
106
|
};
|
|
78
|
-
upload().catch((error) =>
|
|
107
|
+
upload().catch((error) => {
|
|
108
|
+
uploadSpinner.error("Upload failed");
|
|
109
|
+
sendBack({ type: "Error", error: error.message });
|
|
110
|
+
});
|
|
79
111
|
}),
|
|
80
112
|
},
|
|
81
113
|
actions: {
|
|
114
|
+
printLogo,
|
|
115
|
+
showError,
|
|
116
|
+
showConfigInstructions: ({ context }) => printInstallInstructions(context.configError),
|
|
117
|
+
startBundlingSpinner: () => {
|
|
118
|
+
bundlingSpinner.start("Bundling JavaScript...");
|
|
119
|
+
},
|
|
120
|
+
successBundlingSpinner: () => {
|
|
121
|
+
bundlingSpinner.success("Bundling complete");
|
|
122
|
+
},
|
|
123
|
+
errorBundlingSpinner: () => {
|
|
124
|
+
bundlingSpinner.error("Bundling failed");
|
|
125
|
+
},
|
|
82
126
|
clearError: assign({
|
|
83
127
|
error: () => undefined,
|
|
84
128
|
}),
|
|
129
|
+
setUpgradeType: assign({
|
|
130
|
+
upgradeType: (_, params) => params.output,
|
|
131
|
+
}),
|
|
85
132
|
setError: assign({
|
|
86
133
|
error: (_, params) => params.error,
|
|
87
134
|
}),
|
|
135
|
+
setVersions: assign({
|
|
136
|
+
versions: (_, params) => params.versions,
|
|
137
|
+
}),
|
|
88
138
|
setDeveloperConfig: assign({
|
|
89
139
|
developer: (_, params) => params,
|
|
90
140
|
}),
|
|
@@ -105,6 +155,8 @@ export const createVersionMachine = setup({
|
|
|
105
155
|
context: {
|
|
106
156
|
developer: { slug: "", token: "" },
|
|
107
157
|
config: emptyConfig,
|
|
158
|
+
upgradeType: "minor",
|
|
159
|
+
versions: [],
|
|
108
160
|
},
|
|
109
161
|
id: "Create Version Machine",
|
|
110
162
|
states: {
|
|
@@ -125,6 +177,7 @@ export const createVersionMachine = setup({
|
|
|
125
177
|
},
|
|
126
178
|
"Show config instructions": {
|
|
127
179
|
type: "final",
|
|
180
|
+
entry: "showConfigInstructions",
|
|
128
181
|
},
|
|
129
182
|
"Loading App Config": {
|
|
130
183
|
invoke: {
|
|
@@ -144,6 +197,7 @@ export const createVersionMachine = setup({
|
|
|
144
197
|
},
|
|
145
198
|
"Error": {
|
|
146
199
|
type: "final",
|
|
200
|
+
entry: { type: "showError", params: ({ context }) => ({ error: context.error }) },
|
|
147
201
|
},
|
|
148
202
|
"Creating version": {
|
|
149
203
|
invoke: {
|
|
@@ -175,8 +229,11 @@ export const createVersionMachine = setup({
|
|
|
175
229
|
},
|
|
176
230
|
on: {
|
|
177
231
|
"JavaScript Success": {
|
|
178
|
-
target: "
|
|
179
|
-
actions:
|
|
232
|
+
target: "Fetching Versions",
|
|
233
|
+
actions: [
|
|
234
|
+
{ type: "setJsContents", params: ({ event }) => event },
|
|
235
|
+
"successBundlingSpinner",
|
|
236
|
+
],
|
|
180
237
|
reenter: true,
|
|
181
238
|
},
|
|
182
239
|
"JavaScript Error": ".Build Error",
|
|
@@ -184,10 +241,12 @@ export const createVersionMachine = setup({
|
|
|
184
241
|
states: {
|
|
185
242
|
"Build Error": {
|
|
186
243
|
type: "final",
|
|
244
|
+
entry: "errorBundlingSpinner",
|
|
187
245
|
},
|
|
188
246
|
"Building": {},
|
|
189
247
|
},
|
|
190
248
|
initial: "Building",
|
|
249
|
+
entry: "startBundlingSpinner",
|
|
191
250
|
},
|
|
192
251
|
"Uploading": {
|
|
193
252
|
invoke: {
|
|
@@ -203,8 +262,94 @@ export const createVersionMachine = setup({
|
|
|
203
262
|
target: "Success",
|
|
204
263
|
reenter: true,
|
|
205
264
|
},
|
|
265
|
+
"Error": {
|
|
266
|
+
target: "Error",
|
|
267
|
+
reenter: true,
|
|
268
|
+
actions: { type: "setError", params: ({ event }) => event },
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
"Choose Version Type": {
|
|
273
|
+
invoke: {
|
|
274
|
+
src: "askForUpgradeType",
|
|
275
|
+
input: ({ context }) => ({
|
|
276
|
+
choices: [
|
|
277
|
+
{
|
|
278
|
+
value: "minor",
|
|
279
|
+
name: `Minor (v${context.config.major}.${context.config.minor + 1}) – with bug fixes and/or new features`,
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
value: "major",
|
|
283
|
+
name: `Major (v${context.config.major + 1}.0) – 🚨 WITH BREAKING CHANGES 🚨`,
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
message: "Is this a major version or a minor version?",
|
|
287
|
+
required: true,
|
|
288
|
+
}),
|
|
289
|
+
onDone: [
|
|
290
|
+
{
|
|
291
|
+
target: "Confirm Major Version",
|
|
292
|
+
actions: { type: "setUpgradeType", params: ({ event }) => event },
|
|
293
|
+
reenter: true,
|
|
294
|
+
guard: { type: "is major", params: ({ event }) => event },
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
target: "Creating version",
|
|
298
|
+
reenter: true,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
"Confirm Major Version": {
|
|
304
|
+
invoke: {
|
|
305
|
+
src: "confirm",
|
|
306
|
+
input: {
|
|
307
|
+
message: `Are you sure you want to create a major version with breaking changes?`,
|
|
308
|
+
},
|
|
309
|
+
onDone: [
|
|
310
|
+
{
|
|
311
|
+
target: "Creating version",
|
|
312
|
+
guard: { type: "confirmed", params: ({ event }) => event },
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
target: "Choose Version Type",
|
|
316
|
+
reenter: true,
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
"Determine if first version": {
|
|
322
|
+
always: [
|
|
323
|
+
{
|
|
324
|
+
target: "Creating version",
|
|
325
|
+
guard: { type: "no major version", params: ({ context }) => context },
|
|
326
|
+
reenter: true,
|
|
327
|
+
actions: {
|
|
328
|
+
type: "setUpgradeType",
|
|
329
|
+
params: { output: "initial" },
|
|
330
|
+
},
|
|
331
|
+
description: `We're publishing v1.0`,
|
|
332
|
+
},
|
|
333
|
+
"Choose Version Type",
|
|
334
|
+
],
|
|
335
|
+
},
|
|
336
|
+
"Fetching Versions": {
|
|
337
|
+
invoke: {
|
|
338
|
+
src: "fetchVersions",
|
|
339
|
+
input: ({ context }) => context,
|
|
340
|
+
},
|
|
341
|
+
on: {
|
|
342
|
+
"Versions Fetched": {
|
|
343
|
+
target: "Determine if first version",
|
|
344
|
+
actions: { type: "setVersions", params: ({ event }) => event },
|
|
345
|
+
},
|
|
346
|
+
"Error": {
|
|
347
|
+
target: "Error",
|
|
348
|
+
actions: { type: "setError", params: ({ event }) => event },
|
|
349
|
+
},
|
|
206
350
|
},
|
|
207
351
|
},
|
|
208
352
|
},
|
|
209
353
|
initial: "Loading Developer Config",
|
|
354
|
+
entry: "printLogo",
|
|
210
355
|
});
|