attio 0.0.1-experimental.20241226 → 0.0.1-experimental.20250101
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 +7 -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 +121 -4
- 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 +33 -0
- 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/schema.js +2 -2
- 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 } 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,38 @@ 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.config.major === 0,
|
|
31
|
+
},
|
|
22
32
|
actors: {
|
|
33
|
+
confirm,
|
|
34
|
+
askForUpgradeType: askWithTypedChoices(),
|
|
23
35
|
javascript: jsMachine,
|
|
24
|
-
createVersion: fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, }, }) => {
|
|
36
|
+
createVersion: fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, upgradeType, }, }) => {
|
|
25
37
|
const add = async () => {
|
|
38
|
+
const spinner = new Spinner();
|
|
39
|
+
spinner.start("Creating version...");
|
|
26
40
|
try {
|
|
27
41
|
const res = await createVersion({
|
|
28
42
|
token,
|
|
29
43
|
devSlug,
|
|
30
44
|
appId: config.id,
|
|
45
|
+
major: upgradeType === "major" ? config.major + 1 : config.major,
|
|
31
46
|
});
|
|
47
|
+
spinner.success("Version created");
|
|
32
48
|
sendBack({ type: "Version Created", version: res });
|
|
33
49
|
}
|
|
34
50
|
catch (error) {
|
|
51
|
+
spinner.error("Error creating version");
|
|
35
52
|
sendBack({ type: "Error", error: error.message });
|
|
36
53
|
}
|
|
37
54
|
};
|
|
@@ -41,6 +58,8 @@ export const createVersionMachine = setup({
|
|
|
41
58
|
loadAppConfig,
|
|
42
59
|
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, }, }, }) => {
|
|
43
60
|
const upload = async () => {
|
|
61
|
+
const uploadSpinner = new Spinner();
|
|
62
|
+
uploadSpinner.start("Uploading...");
|
|
44
63
|
const [clientBundle, serverBundle] = jsContents;
|
|
45
64
|
await Promise.all([
|
|
46
65
|
fetch(client_bundle_upload_url, {
|
|
@@ -60,6 +79,9 @@ export const createVersionMachine = setup({
|
|
|
60
79
|
},
|
|
61
80
|
}),
|
|
62
81
|
]);
|
|
82
|
+
uploadSpinner.success("Uploading complete");
|
|
83
|
+
const signSpinner = new Spinner();
|
|
84
|
+
signSpinner.start("Signing bundles...");
|
|
63
85
|
await completeProdBundleUpload({
|
|
64
86
|
token,
|
|
65
87
|
developerSlug,
|
|
@@ -68,20 +90,37 @@ export const createVersionMachine = setup({
|
|
|
68
90
|
minor,
|
|
69
91
|
bundleId,
|
|
70
92
|
});
|
|
93
|
+
signSpinner.success("Bundles signed");
|
|
71
94
|
updateAppConfig((config) => ({
|
|
72
95
|
...config,
|
|
73
96
|
major,
|
|
74
97
|
minor,
|
|
75
98
|
}));
|
|
99
|
+
process.stdout.write(`\nVersion ${chalk.green(`${major}.${minor}`)} created!\n\n`);
|
|
76
100
|
sendBack({ type: "Upload Complete" });
|
|
77
101
|
};
|
|
78
102
|
upload().catch((error) => sendBack({ type: "Upload Error", error }));
|
|
79
103
|
}),
|
|
80
104
|
},
|
|
81
105
|
actions: {
|
|
106
|
+
printLogo,
|
|
107
|
+
showError,
|
|
108
|
+
showConfigInstructions: ({ context }) => printInstallInstructions(context.configError),
|
|
109
|
+
startBundlingSpinner: () => {
|
|
110
|
+
bundlingSpinner.start("Bundling JavaScript...");
|
|
111
|
+
},
|
|
112
|
+
successBundlingSpinner: () => {
|
|
113
|
+
bundlingSpinner.success("Bundling complete");
|
|
114
|
+
},
|
|
115
|
+
errorBundlingSpinner: () => {
|
|
116
|
+
bundlingSpinner.error("Bundling failed");
|
|
117
|
+
},
|
|
82
118
|
clearError: assign({
|
|
83
119
|
error: () => undefined,
|
|
84
120
|
}),
|
|
121
|
+
setUpgradeType: assign({
|
|
122
|
+
upgradeType: (_, params) => params.output,
|
|
123
|
+
}),
|
|
85
124
|
setError: assign({
|
|
86
125
|
error: (_, params) => params.error,
|
|
87
126
|
}),
|
|
@@ -105,6 +144,7 @@ export const createVersionMachine = setup({
|
|
|
105
144
|
context: {
|
|
106
145
|
developer: { slug: "", token: "" },
|
|
107
146
|
config: emptyConfig,
|
|
147
|
+
upgradeType: "minor",
|
|
108
148
|
},
|
|
109
149
|
id: "Create Version Machine",
|
|
110
150
|
states: {
|
|
@@ -125,6 +165,7 @@ export const createVersionMachine = setup({
|
|
|
125
165
|
},
|
|
126
166
|
"Show config instructions": {
|
|
127
167
|
type: "final",
|
|
168
|
+
entry: "showConfigInstructions",
|
|
128
169
|
},
|
|
129
170
|
"Loading App Config": {
|
|
130
171
|
invoke: {
|
|
@@ -144,6 +185,7 @@ export const createVersionMachine = setup({
|
|
|
144
185
|
},
|
|
145
186
|
"Error": {
|
|
146
187
|
type: "final",
|
|
188
|
+
entry: { type: "showError", params: ({ context }) => ({ error: context.error }) },
|
|
147
189
|
},
|
|
148
190
|
"Creating version": {
|
|
149
191
|
invoke: {
|
|
@@ -175,8 +217,11 @@ export const createVersionMachine = setup({
|
|
|
175
217
|
},
|
|
176
218
|
on: {
|
|
177
219
|
"JavaScript Success": {
|
|
178
|
-
target: "
|
|
179
|
-
actions:
|
|
220
|
+
target: "Determine if first version",
|
|
221
|
+
actions: [
|
|
222
|
+
{ type: "setJsContents", params: ({ event }) => event },
|
|
223
|
+
"successBundlingSpinner",
|
|
224
|
+
],
|
|
180
225
|
reenter: true,
|
|
181
226
|
},
|
|
182
227
|
"JavaScript Error": ".Build Error",
|
|
@@ -184,10 +229,12 @@ export const createVersionMachine = setup({
|
|
|
184
229
|
states: {
|
|
185
230
|
"Build Error": {
|
|
186
231
|
type: "final",
|
|
232
|
+
entry: "errorBundlingSpinner",
|
|
187
233
|
},
|
|
188
234
|
"Building": {},
|
|
189
235
|
},
|
|
190
236
|
initial: "Building",
|
|
237
|
+
entry: "startBundlingSpinner",
|
|
191
238
|
},
|
|
192
239
|
"Uploading": {
|
|
193
240
|
invoke: {
|
|
@@ -203,8 +250,78 @@ export const createVersionMachine = setup({
|
|
|
203
250
|
target: "Success",
|
|
204
251
|
reenter: true,
|
|
205
252
|
},
|
|
253
|
+
"Upload Error": {
|
|
254
|
+
target: "Error",
|
|
255
|
+
reenter: true,
|
|
256
|
+
actions: "setError",
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
"Choose Version Type": {
|
|
261
|
+
invoke: {
|
|
262
|
+
src: "askForUpgradeType",
|
|
263
|
+
input: ({ context }) => ({
|
|
264
|
+
choices: [
|
|
265
|
+
{
|
|
266
|
+
value: "minor",
|
|
267
|
+
name: `Minor (v${context.config.major}.${context.config.minor + 1}) – with bug fixes and/or new features`,
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
value: "major",
|
|
271
|
+
name: `Major (v${context.config.major + 1}.0) – 🚨 WITH BREAKING CHANGES 🚨`,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
message: "Is this a major version or a minor version?",
|
|
275
|
+
required: true,
|
|
276
|
+
}),
|
|
277
|
+
onDone: [
|
|
278
|
+
{
|
|
279
|
+
target: "Confirm Major Version",
|
|
280
|
+
actions: { type: "setUpgradeType", params: ({ event }) => event },
|
|
281
|
+
reenter: true,
|
|
282
|
+
guard: { type: "is major", params: ({ event }) => event },
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
target: "Creating version",
|
|
286
|
+
reenter: true,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
"Confirm Major Version": {
|
|
292
|
+
invoke: {
|
|
293
|
+
src: "confirm",
|
|
294
|
+
input: {
|
|
295
|
+
message: `Are you sure you want to create a major version with breaking changes?`,
|
|
296
|
+
},
|
|
297
|
+
onDone: [
|
|
298
|
+
{
|
|
299
|
+
target: "Creating version",
|
|
300
|
+
guard: { type: "confirmed", params: ({ event }) => event },
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
target: "Choose Version Type",
|
|
304
|
+
reenter: true,
|
|
305
|
+
},
|
|
306
|
+
],
|
|
206
307
|
},
|
|
207
308
|
},
|
|
309
|
+
"Determine if first version": {
|
|
310
|
+
always: [
|
|
311
|
+
{
|
|
312
|
+
target: "Creating version",
|
|
313
|
+
guard: { type: "no major version", params: ({ context }) => context },
|
|
314
|
+
reenter: true,
|
|
315
|
+
actions: {
|
|
316
|
+
type: "setUpgradeType",
|
|
317
|
+
params: { output: "major" },
|
|
318
|
+
},
|
|
319
|
+
description: `We're publishing v1.0`,
|
|
320
|
+
},
|
|
321
|
+
"Choose Version Type",
|
|
322
|
+
],
|
|
323
|
+
},
|
|
208
324
|
},
|
|
209
325
|
initial: "Loading Developer Config",
|
|
326
|
+
entry: "printLogo",
|
|
210
327
|
});
|