attio 0.0.1-experimental.20250328 → 0.0.1-experimental.20250328.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.
package/lib/api/auth.js CHANGED
@@ -74,9 +74,7 @@ export async function auth() {
74
74
  return c.html(`
75
75
  <html>
76
76
  <body>
77
- <h1>Authentication Successful</h1>
78
- <p>You can close this window and return to the CLI.</p>
79
- <script>window.close();</script>
77
+ <script>window.location.href = '${APP}/authorized';</script>
80
78
  </body>
81
79
  </html>
82
80
  `);
@@ -2,8 +2,15 @@ import { auth as authApi } from "./auth.js";
2
2
  import { deleteAuthToken, loadAuthToken } from "./keychain.js";
3
3
  import { whoami } from "./whoami.js";
4
4
  async function auth() {
5
- process.stdout.write("You need to log in with Attio.\n\n");
6
5
  await deleteAuthToken();
6
+ if (process.env.NODE_ENV !== "test") {
7
+ process.stdout.write("You need to log in with Attio. Press Enter to continue...\n\n");
8
+ await new Promise((resolve) => {
9
+ process.stdin.once("data", () => {
10
+ resolve();
11
+ });
12
+ });
13
+ }
7
14
  return await authApi();
8
15
  }
9
16
  export async function ensureAuthed() {
@@ -1,11 +1,10 @@
1
- import Spinner from "tiny-spinner";
2
1
  import notifier from "node-notifier";
3
2
  import { startUpload } from "../../api/start-upload.js";
4
3
  import { completeBundleUpload } from "../../api/complete-bundle-upload.js";
4
+ import { Spinner } from "../../util/spinner.js";
5
5
  export async function upload({ token, contents, devVersionId, appId, }) {
6
- const spinner = new Spinner();
6
+ const spinner = new Spinner().start("Uploading...");
7
7
  try {
8
- spinner.start("Uploading...");
9
8
  const { client_bundle_upload_url, server_bundle_upload_url, app_dev_version_bundle_id: bundleId, } = await startUpload({
10
9
  token,
11
10
  appId,
@@ -1,25 +1,28 @@
1
1
  import { Command, Option } from "commander";
2
2
  import { z } from "zod";
3
3
  import chalk from "chalk";
4
- import { boot } from "./dev/boot.js";
5
- import { bundleJavaScript } from "./dev/bundle-javascript.js";
6
- import { upload } from "./dev/upload.js";
7
4
  import { printMessage } from "../util/print-message.js";
8
- import { onboarding } from "./dev/onboarding.js";
9
5
  import { validateTypeScript } from "./dev/validate-typescript.js";
10
6
  import { graphqlCodeGen } from "./dev/graphql-code-gen.js";
7
+ import { bundleJavaScript } from "./dev/bundle-javascript.js";
8
+ import { boot } from "./dev/boot.js";
9
+ import { onboarding } from "./dev/onboarding.js";
10
+ import { graphqlServer } from "./dev/graphql-server.js";
11
+ import { upload } from "./dev/upload.js";
11
12
  export const optionsSchema = z.object({
12
13
  workspace: z.string().optional(),
13
14
  });
14
15
  export const dev = new Command("dev")
15
16
  .description("Develop your Attio app")
16
17
  .addOption(new Option("--dev", "Run in development mode (additional debugging info)"))
17
- .addOption(new Option("--workspace", "The slug of the workspace to use"))
18
+ .addOption(new Option("--workspace <slug>", "The slug of the workspace to use"))
18
19
  .action(async (unparsedOptions) => {
19
20
  const { workspace: workspaceSlug } = optionsSchema.parse(unparsedOptions);
20
21
  const cleanupFunctions = [];
21
22
  try {
22
- const { token, appId, devVersionId, appSlug, workspace } = await boot({ workspaceSlug });
23
+ const { token, appId, appSlug, workspace, devVersionId } = await boot({ workspaceSlug });
24
+ const cleanupGraphqlServer = graphqlServer();
25
+ cleanupFunctions.push(cleanupGraphqlServer);
23
26
  const cleanupOnboardingDaemon = onboarding({ token, appId, appSlug, workspace });
24
27
  cleanupFunctions.push(cleanupOnboardingDaemon);
25
28
  const [cleanupTs, triggerTs] = validateTypeScript();
@@ -4,11 +4,11 @@ import { fromCallback, fromPromise } from "xstate";
4
4
  import { readFileSync } from "fs";
5
5
  import { join } from "path";
6
6
  import { z } from "zod";
7
- import Spinner from "tiny-spinner";
8
7
  import { getAppInfo } from "../api/get-app-info.js";
9
8
  import { ensureAuthed } from "../api/ensure-authed.js";
10
9
  import { fetchWorkspaces } from "../api/fetch-workspaces.js";
11
10
  import { APP } from "../env.js";
11
+ import { Spinner } from "../util/spinner.js";
12
12
  export const authenticate = fromPromise(ensureAuthed);
13
13
  const packageJsonSchema = z.object({
14
14
  name: z.string({
@@ -1,10 +1,10 @@
1
1
  import { assign, setup } from "xstate";
2
- import Spinner from "tiny-spinner";
3
2
  import { codeGenMachine } from "./code-gen-machine.js";
4
3
  import { jsMachine } from "./js-machine.js";
5
4
  import { tsMachine } from "./ts-machine.js";
6
5
  import { printJsError, printTsError } from "../util/typescript.js";
7
6
  import { printLogo } from "./actions.js";
7
+ import { Spinner } from "../util/spinner.js";
8
8
  const processes = ["javascript", "typescript"];
9
9
  const spinner = new Spinner();
10
10
  export const buildMachine = setup({
@@ -5,8 +5,8 @@ import { createVersion } from "../api/create-version.js";
5
5
  import { authenticate, confirm, fetchVersions, loadAppInfo, loadAppSlug } from "./actors.js";
6
6
  import { jsMachine } from "./js-machine.js";
7
7
  import { printLogo, showActorError } from "./actions.js";
8
- import Spinner from "tiny-spinner";
9
8
  import { loadAttioCliPackageJson } from "../util/load-attio-cli-package-json.js";
9
+ import { Spinner } from "../util/spinner.js";
10
10
  export const connectionTypes = [
11
11
  { value: "secret", label: "Secret" },
12
12
  { value: "oauth2-code", label: "OAuth2" },
@@ -1,15 +1,15 @@
1
1
  import { existsSync } from "fs";
2
- import Spinner from "tiny-spinner";
3
2
  import path, { join } from "path";
4
3
  import { fileURLToPath } from "url";
5
4
  import { assign, setup, fromPromise } from "xstate";
5
+ import chalk from "chalk";
6
+ import boxen from "boxen";
6
7
  import { copyWithTransform } from "../util/copy-with-replace.js";
7
8
  import { createDirectory } from "../util/create-directory.js";
8
9
  import { canWrite } from "../util/validate-slug.js";
9
10
  import { ask, askWithChoices, authenticate, loadAppInfo } from "./actors.js";
10
11
  import { printLogo, showActorError } from "./actions.js";
11
- import chalk from "chalk";
12
- import boxen from "boxen";
12
+ import { Spinner } from "../util/spinner.js";
13
13
  export const languages = [
14
14
  { name: "TypeScript (recommended)", value: "typescript" },
15
15
  { name: "JavaScript", value: "javascript" },
@@ -0,0 +1,46 @@
1
+ import chalk from "chalk";
2
+ const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
3
+ export class Spinner {
4
+ frameIndex = 0;
5
+ stopped = false;
6
+ interval = null;
7
+ message = "";
8
+ start(message) {
9
+ if (this.interval) {
10
+ clearInterval(this.interval);
11
+ }
12
+ this.message = message;
13
+ this.stopped = false;
14
+ this.interval = setInterval(() => {
15
+ if (this.stopped)
16
+ return;
17
+ const frame = frames[(this.frameIndex = ++this.frameIndex % frames.length)];
18
+ process.stdout.write(`\r${frame} ${this.message}`);
19
+ }, 80);
20
+ return this;
21
+ }
22
+ update(message) {
23
+ this.message = message;
24
+ return this;
25
+ }
26
+ stop(message) {
27
+ this.stopped = true;
28
+ if (this.interval) {
29
+ clearInterval(this.interval);
30
+ this.interval = null;
31
+ }
32
+ if (message) {
33
+ process.stdout.write(`\r${message} \n`);
34
+ }
35
+ return this;
36
+ }
37
+ success(message) {
38
+ return this.stop(`${chalk.green("✓")} ${message}`);
39
+ }
40
+ error(message) {
41
+ return this.stop(`${chalk.red("✖")} ${message}`);
42
+ }
43
+ warning(message) {
44
+ return this.stop(`${chalk.yellow("⚠")} ${message}`);
45
+ }
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attio",
3
- "version": "0.0.1-experimental.20250328",
3
+ "version": "0.0.1-experimental.20250328.1",
4
4
  "bin": "lib/attio.js",
5
5
  "type": "module",
6
6
  "files": [
@@ -64,7 +64,6 @@
64
64
  "react": "18.3.1",
65
65
  "stdin-blocker": "^2.0.0",
66
66
  "tiny-cursor": "^2.0.0",
67
- "tiny-spinner": "^2.0.4",
68
67
  "tmp-promise": "^3.0.3",
69
68
  "ts-morph": "^24.0.0",
70
69
  "typescript": "5.6.3",