attio 0.0.1-experimental.20250328.1 → 0.0.1-experimental.20250401.1

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.
Files changed (39) hide show
  1. package/lib/api/determine-workspace.spinner.js +39 -0
  2. package/lib/api/{get-app-info.js → fetch-app-info.js} +1 -1
  3. package/lib/api/fetch-workspaces.js +11 -0
  4. package/lib/api/get-app-info.spinner.js +18 -0
  5. package/lib/api/get-app-slug-from-package-json.js +26 -0
  6. package/lib/api/get-versions.spinner.js +21 -0
  7. package/lib/commands/build/build-javascript.js +24 -0
  8. package/lib/commands/build/validate-typescript.js +30 -0
  9. package/lib/commands/build.js +32 -16
  10. package/lib/commands/dev/boot.js +4 -4
  11. package/lib/commands/dev/build-javascript.js +2 -2
  12. package/lib/commands/dev/bundle-javascript.js +1 -1
  13. package/lib/commands/dev/prepare-build-contexts.js +3 -3
  14. package/lib/commands/init/ask-language.js +11 -0
  15. package/lib/commands/init/boot.js +14 -0
  16. package/lib/commands/init/create-project.js +50 -0
  17. package/lib/commands/init.js +23 -16
  18. package/lib/commands/login.js +2 -0
  19. package/lib/commands/logout.js +2 -0
  20. package/lib/commands/version/create/boot.js +9 -0
  21. package/lib/commands/version/create.js +71 -15
  22. package/lib/commands/version/list.js +4 -2
  23. package/lib/commands/whoami.js +2 -1
  24. package/lib/util/{validate-slug.js → can-write.js} +0 -2
  25. package/lib/util/print-logo.js +5 -0
  26. package/lib/util/print-message.js +3 -2
  27. package/package.json +2 -14
  28. package/lib/api/create-developer-account.js +0 -36
  29. package/lib/machines/actions.js +0 -8
  30. package/lib/machines/actors.js +0 -123
  31. package/lib/machines/build-machine.js +0 -192
  32. package/lib/machines/build-orchestrator.js +0 -1
  33. package/lib/machines/code-gen-machine.js +0 -97
  34. package/lib/machines/create-version-machine.js +0 -308
  35. package/lib/machines/env-machine.js +0 -82
  36. package/lib/machines/init-machine.js +0 -192
  37. package/lib/machines/js-machine.js +0 -231
  38. package/lib/machines/ts-machine.js +0 -105
  39. package/lib/util/set-terminal-title.js +0 -8
@@ -1,231 +0,0 @@
1
- import * as esbuild from "esbuild";
2
- import fs from "fs/promises";
3
- import path from "path";
4
- import tmp from "tmp-promise";
5
- import { assign, setup, fromCallback, sendTo } from "xstate";
6
- import { errorsAndWarningsSchema } from "../build.js";
7
- import { createClientBuildConfig } from "../build/client/create-client-build-config.js";
8
- import { generateClientEntry } from "../build/client/generate-client-entry.js";
9
- import { createServerBuildConfig } from "../build/server/create-server-build-config.js";
10
- import { generateServerEntry } from "../build/server/generate-server-entry.js";
11
- export const jsMachine = setup({
12
- types: {
13
- context: {},
14
- events: {},
15
- input: {},
16
- },
17
- guards: {
18
- "has errors": (_, params) => Boolean(params.errors),
19
- },
20
- actors: {
21
- prepareBuildContext: fromCallback(({ sendBack, input: { write } }) => {
22
- let buildContexts;
23
- const prepare = async () => {
24
- const srcDir = "src";
25
- const assetsDir = path.join(srcDir, "assets");
26
- const webhooksDir = path.join(srcDir, "webhooks");
27
- const eventsDir = path.join(srcDir, "events");
28
- buildContexts = (await Promise.all([
29
- tmp.file({ postfix: ".js" }).then(async (tempFile) => {
30
- let lastJS;
31
- const updateTempFile = async () => {
32
- const js = await generateClientEntry({
33
- srcDirAbsolute: path.resolve(srcDir),
34
- assetsDirAbsolute: path.resolve(assetsDir),
35
- });
36
- if (js === lastJS) {
37
- return;
38
- }
39
- lastJS = js;
40
- await fs.writeFile(tempFile.path, js);
41
- };
42
- const esbuildContext = await esbuild.context({
43
- ...createClientBuildConfig({
44
- entryPoint: tempFile.path,
45
- srcDir,
46
- }),
47
- write,
48
- outfile: path.resolve("dist", "index.js"),
49
- loader: { ".png": "dataurl", ".graphql": "text", ".gql": "text" },
50
- });
51
- return {
52
- rebuild: async () => {
53
- await updateTempFile();
54
- return esbuildContext.rebuild();
55
- },
56
- dispose: async () => {
57
- await Promise.all([
58
- esbuildContext.dispose(),
59
- tempFile.cleanup(),
60
- ]);
61
- },
62
- };
63
- }),
64
- tmp.file({ postfix: ".js" }).then(async (tempFile) => {
65
- let lastJS;
66
- const updateTempFile = async () => {
67
- const js = await generateServerEntry({
68
- srcDirAbsolute: path.resolve(srcDir),
69
- webhooksDirAbsolute: path.resolve(webhooksDir),
70
- eventDirAbsolute: path.resolve(eventsDir),
71
- });
72
- if (js === lastJS) {
73
- return;
74
- }
75
- lastJS = js;
76
- await fs.writeFile(tempFile.path, js);
77
- };
78
- const esbuildContext = await esbuild.context({
79
- ...createServerBuildConfig(tempFile.path),
80
- write,
81
- outfile: path.resolve("dist", "server.js"),
82
- });
83
- return {
84
- rebuild: async () => {
85
- await updateTempFile();
86
- return esbuildContext.rebuild();
87
- },
88
- dispose: async () => {
89
- await Promise.all([
90
- esbuildContext.dispose(),
91
- tempFile.cleanup(),
92
- ]);
93
- },
94
- };
95
- }),
96
- ])).flat();
97
- sendBack({
98
- type: "Build Contexts Prepared",
99
- buildContexts,
100
- });
101
- };
102
- prepare();
103
- return async () => {
104
- if (!buildContexts)
105
- return;
106
- await Promise.all(buildContexts.map(async (context) => context.dispose()));
107
- };
108
- }),
109
- build: fromCallback(({ sendBack, input }) => {
110
- const { buildContexts, write } = input;
111
- const build = async () => {
112
- try {
113
- const results = await Promise.all(buildContexts.map(async (buildContext) => buildContext.rebuild()));
114
- sendBack({
115
- type: "Result",
116
- contents: write
117
- ? ["", ""]
118
- : results.map((result) => result.outputFiles[0].text),
119
- time: new Date(),
120
- });
121
- }
122
- catch (e) {
123
- sendBack({
124
- type: "Result",
125
- errors: errorsAndWarningsSchema.parse(e),
126
- time: new Date(),
127
- });
128
- }
129
- };
130
- build();
131
- }),
132
- },
133
- actions: {
134
- clearErrors: assign({
135
- errors: () => undefined,
136
- }),
137
- raiseErrored: sendTo(({ context }) => context.parentRef, (_, params) => ({
138
- type: "JavaScript Error",
139
- errors: params.errors,
140
- })),
141
- raiseSuccess: sendTo(({ context }, _params) => context.parentRef, (_, params) => ({
142
- type: "JavaScript Success",
143
- contents: params.contents,
144
- time: params.time,
145
- })),
146
- setBuildContexts: assign({
147
- buildContexts: (_, params) => params.buildContexts,
148
- }),
149
- setError: assign({
150
- errors: (_, params) => params.errors,
151
- }),
152
- setTime: assign({
153
- time: (_, params) => params.time,
154
- }),
155
- },
156
- }).createMachine({
157
- id: "JavaScript Machine",
158
- initial: "Preparing",
159
- context: ({ input }) => ({
160
- ...input,
161
- buildContexts: [],
162
- }),
163
- states: {
164
- Preparing: {
165
- on: {
166
- "Build Contexts Prepared": {
167
- target: "Watching",
168
- actions: {
169
- type: "setBuildContexts",
170
- params: ({ event }) => event,
171
- },
172
- },
173
- },
174
- },
175
- Watching: {
176
- states: {
177
- Success: {},
178
- Building: {
179
- on: {
180
- Result: [
181
- {
182
- target: "Errored",
183
- guard: {
184
- type: "has errors",
185
- params: ({ event }) => event,
186
- },
187
- actions: [
188
- {
189
- type: "setError",
190
- params: ({ event }) => ({ errors: event.errors }),
191
- },
192
- {
193
- type: "raiseErrored",
194
- params: ({ event }) => ({ errors: event.errors }),
195
- },
196
- ],
197
- },
198
- {
199
- target: "Success",
200
- actions: [
201
- { type: "setTime", params: ({ event }) => event },
202
- {
203
- type: "raiseSuccess",
204
- params: ({ event }) => ({
205
- contents: event.contents,
206
- time: event.time,
207
- }),
208
- },
209
- "clearErrors",
210
- ],
211
- },
212
- ],
213
- },
214
- invoke: {
215
- src: "build",
216
- input: ({ context }) => context,
217
- },
218
- },
219
- Errored: {},
220
- },
221
- initial: "Building",
222
- on: {
223
- Change: ".Building",
224
- },
225
- },
226
- },
227
- invoke: {
228
- src: "prepareBuildContext",
229
- input: ({ context }) => context,
230
- },
231
- });
@@ -1,105 +0,0 @@
1
- import path from "path";
2
- import { sendTo, assign, setup, fromCallback } from "xstate";
3
- import { getDiagnostics, readConfig, typeScriptErrorSchema, } from "../util/typescript.js";
4
- export const tsMachine = setup({
5
- types: {
6
- context: {},
7
- events: {},
8
- input: {},
9
- },
10
- guards: {
11
- "has errors": (_, params) => Boolean(params.errors?.length),
12
- },
13
- actors: {
14
- validate: fromCallback(({ sendBack }) => {
15
- const validate = async () => {
16
- try {
17
- const program = await readConfig(path.resolve("tsconfig.json"));
18
- if (program === "Not a TypeScript project") {
19
- sendBack({ type: "Result", time: new Date() });
20
- return;
21
- }
22
- const errors = await getDiagnostics(program);
23
- if (errors.length) {
24
- sendBack({ type: "Result", errors, time: new Date() });
25
- }
26
- else {
27
- sendBack({ type: "Result", time: new Date() });
28
- }
29
- }
30
- catch (e) {
31
- sendBack({
32
- type: "Result",
33
- errors: [
34
- typeScriptErrorSchema.parse({ text: e.message ?? "ERROR" }),
35
- ],
36
- time: new Date(),
37
- });
38
- }
39
- };
40
- validate();
41
- }),
42
- },
43
- actions: {
44
- clearError: assign({
45
- errors: () => undefined,
46
- }),
47
- clearTime: assign({
48
- time: () => undefined,
49
- }),
50
- raiseErrored: sendTo(({ context }) => context.parentRef, ({ context }) => ({
51
- type: "TypeScript Error",
52
- errors: context.errors,
53
- })),
54
- raiseSuccess: sendTo(({ context }) => context.parentRef, { type: "TypeScript Success" }),
55
- setErrors: assign({
56
- errors: (_, params) => params.errors,
57
- }),
58
- setTime: assign({
59
- time: (_, params) => params.time,
60
- }),
61
- },
62
- }).createMachine({
63
- id: "TypeScript Machine",
64
- context: ({ input }) => ({
65
- parentRef: input.parentRef,
66
- }),
67
- states: {
68
- Validating: {
69
- on: {
70
- Result: [
71
- {
72
- target: "Errored",
73
- actions: [
74
- {
75
- type: "setErrors",
76
- params: ({ event }) => event,
77
- },
78
- { type: "setTime", params: ({ event }) => event },
79
- ],
80
- guard: { type: "has errors", params: ({ event }) => event },
81
- },
82
- {
83
- target: "Success",
84
- reenter: true,
85
- actions: ["clearError", { type: "setTime", params: ({ event }) => event }],
86
- },
87
- ],
88
- },
89
- invoke: {
90
- src: "validate",
91
- },
92
- entry: "clearTime",
93
- },
94
- Errored: {
95
- entry: "raiseErrored",
96
- },
97
- Success: {
98
- entry: "raiseSuccess",
99
- },
100
- },
101
- initial: "Validating",
102
- on: {
103
- Change: ".Validating",
104
- },
105
- });
@@ -1,8 +0,0 @@
1
- export function setTerminalTitle(title) {
2
- if (process.platform === "win32") {
3
- process.title = title;
4
- }
5
- else {
6
- process.stdout.write(`\x1B]2;${title}\x1B\x5C`);
7
- }
8
- }