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,72 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import Spinner from "ink-spinner";
|
|
4
|
-
import { argument, option } from "pastel";
|
|
5
|
-
import React from "react";
|
|
1
|
+
import { Argument, Command, Option } from "commander";
|
|
2
|
+
import { createActor } from "xstate";
|
|
6
3
|
import { z } from "zod";
|
|
7
|
-
import { InitialInstructions } from "../../components/InitialInstructions.js";
|
|
8
|
-
import { Logo } from "../../components/Logo.js";
|
|
9
|
-
import { Select } from "../../components/Select.js";
|
|
10
4
|
import { publishVersionMachine } from "../../machines/publish-version-machine.js";
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
name: "version",
|
|
19
|
-
description: `The version to publish (e.g: "1.0"). If you don't specify a version, you will be prompted to choose.`,
|
|
20
|
-
})),
|
|
21
|
-
]);
|
|
22
|
-
export const options = z.object({
|
|
23
|
-
dev: z
|
|
24
|
-
.boolean()
|
|
25
|
-
.default(false)
|
|
26
|
-
.describe(option({ description: "Run in development mode (additional debugging info)" })),
|
|
5
|
+
export const argsSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^\d+\.\d+$/, 'Version must be in the format "major.minor" (e.g., "1.0")')
|
|
8
|
+
.optional()
|
|
9
|
+
.describe(`The version to invite someone to (e.g: "1.0"). If you don't specify a version, you will be prompted to choose.`);
|
|
10
|
+
export const optionsSchema = z.object({
|
|
11
|
+
dev: z.boolean().default(false),
|
|
27
12
|
});
|
|
28
|
-
export
|
|
29
|
-
|
|
13
|
+
export const versionPublish = new Command("publish")
|
|
14
|
+
.description("Publish an unpublished production version of your Attio app")
|
|
15
|
+
.addArgument(new Argument("<version>", `The version to publish (e.g: "1.0"). If you don't specify a version, you will be prompted to choose.`).argOptional())
|
|
16
|
+
.addOption(new Option("--dev", "Run in development mode (additional debugging info)"))
|
|
17
|
+
.action((unparsedArgs, unparsedOptions) => {
|
|
18
|
+
const versionResult = argsSchema.safeParse(unparsedArgs);
|
|
19
|
+
const optionsResult = optionsSchema.safeParse(unparsedOptions);
|
|
20
|
+
if (!versionResult.success) {
|
|
21
|
+
process.stderr.write("\nInvalid version argument:\n");
|
|
22
|
+
versionResult.error.errors.forEach((err) => {
|
|
23
|
+
process.stderr.write(`- ${err.message}\n`);
|
|
24
|
+
});
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
if (!optionsResult.success) {
|
|
28
|
+
process.stderr.write("\nInvalid options:\n");
|
|
29
|
+
optionsResult.error.errors.forEach((err) => {
|
|
30
|
+
process.stderr.write(`- ${err.path.map((p) => String(p).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)).join(".")}: ${err.message}\n`);
|
|
31
|
+
});
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const version = versionResult.data;
|
|
35
|
+
const options = optionsResult.data;
|
|
36
|
+
const actor = createActor(publishVersionMachine, {
|
|
30
37
|
input: {
|
|
31
38
|
major: version ? Number(version.split(".")[0]) : undefined,
|
|
32
39
|
minor: version ? Number(version.split(".")[1]) : undefined,
|
|
33
40
|
},
|
|
34
41
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
snapshot.matches("Ask for version") && (React.createElement(Box, { flexDirection: "column" },
|
|
43
|
-
React.createElement(Box, null,
|
|
44
|
-
React.createElement(Text, null, "Select a version to publish:")),
|
|
45
|
-
React.createElement(Box, null,
|
|
46
|
-
React.createElement(Select, { items: snapshot.context.versions.map((version) => ({
|
|
47
|
-
label: `${version.major}.${version.minor}`,
|
|
48
|
-
value: version,
|
|
49
|
-
})), onSelect: (version) => send({ type: "Select Version", version }) })))),
|
|
50
|
-
snapshot.matches("No unpublished versions") && (React.createElement(Box, null,
|
|
51
|
-
React.createElement(Text, null, "No unpublished versions found."))),
|
|
52
|
-
snapshot.matches("Publishing") && (React.createElement(Box, null,
|
|
53
|
-
React.createElement(Text, null,
|
|
54
|
-
"\u231B\uFE0F Publishing version ",
|
|
55
|
-
major,
|
|
56
|
-
".",
|
|
57
|
-
minor,
|
|
58
|
-
"...",
|
|
59
|
-
" ",
|
|
60
|
-
React.createElement(Text, { color: "green" },
|
|
61
|
-
React.createElement(Spinner, { type: "dots" }))))),
|
|
62
|
-
snapshot.matches("Success") && (React.createElement(React.Fragment, null,
|
|
63
|
-
React.createElement(Box, null,
|
|
64
|
-
React.createElement(Text, { color: "green" },
|
|
65
|
-
"SUCCESS!! \uD83C\uDF89 Version ",
|
|
66
|
-
major,
|
|
67
|
-
".",
|
|
68
|
-
minor,
|
|
69
|
-
" successfully published.")))),
|
|
70
|
-
snapshot.context.error && (React.createElement(Box, { marginTop: 1 },
|
|
71
|
-
React.createElement(Text, { color: "red" }, snapshot.context.error))))));
|
|
72
|
-
}
|
|
42
|
+
if (options.dev) {
|
|
43
|
+
actor.subscribe((state) => {
|
|
44
|
+
console.log("state:", state.value);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
actor.start();
|
|
48
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { textGradient } from "../util/text-gradient.js";
|
|
3
|
+
import { attioLogoAndName } from "../attio-logo.js";
|
|
4
|
+
export const showError = (_, params) => process.stderr.write(`${chalk.red("✖ " + params.error)}\n`);
|
|
5
|
+
export const printLogo = () => {
|
|
6
|
+
process.stdout.write(`\n${textGradient(attioLogoAndName, "#ff5f6d", "#ffc371")}\n\n`);
|
|
7
|
+
};
|
package/lib/machines/actors.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fetchVersions as fetchVersionsApi } from "../api/fetch-versions.js";
|
|
2
|
+
import { input as inputPrompt, password as passwordPrompt, select as selectPrompt, confirm as confirmPrompt, } from "@inquirer/prompts";
|
|
3
|
+
import { fromCallback, fromPromise } from "xstate";
|
|
2
4
|
import { loadAppConfigFile } from "../util/app-config.js";
|
|
3
5
|
import { loadDeveloperConfig as loadDeveloperConfigFile } from "../util/load-developer-config.js";
|
|
6
|
+
import Spinner from "tiny-spinner";
|
|
4
7
|
export const loadDeveloperConfig = fromCallback(({ sendBack }) => {
|
|
5
8
|
const load = async () => {
|
|
6
9
|
const config = await loadDeveloperConfigFile();
|
|
@@ -24,3 +27,25 @@ export const loadAppConfig = fromCallback(({ sendBack }) => {
|
|
|
24
27
|
}
|
|
25
28
|
sendBack({ type: "App Config Loaded", config });
|
|
26
29
|
});
|
|
30
|
+
export const fetchVersions = fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, }, }) => {
|
|
31
|
+
const spinner = new Spinner();
|
|
32
|
+
spinner.start("Loading versions...");
|
|
33
|
+
const getVersions = async () => {
|
|
34
|
+
const versions = await fetchVersionsApi({
|
|
35
|
+
token,
|
|
36
|
+
devSlug,
|
|
37
|
+
appId: config.id,
|
|
38
|
+
});
|
|
39
|
+
spinner.success("Versions loaded");
|
|
40
|
+
sendBack({ type: "Versions Fetched", versions });
|
|
41
|
+
};
|
|
42
|
+
getVersions().catch((error) => {
|
|
43
|
+
spinner.error("Error loading versions");
|
|
44
|
+
sendBack({ type: "Error", error: error.message });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
export const ask = fromPromise(async ({ input }) => await inputPrompt(input));
|
|
48
|
+
export const askPassword = fromPromise(async ({ input }) => await passwordPrompt(input));
|
|
49
|
+
export const askWithChoices = fromPromise(async ({ input, }) => await selectPrompt(input));
|
|
50
|
+
export const askWithTypedChoices = () => fromPromise(async ({ input, }) => await selectPrompt(input));
|
|
51
|
+
export const confirm = fromPromise(async ({ input }) => await confirmPrompt(input));
|