attio 0.0.1-experimental.20250408 → 0.0.1-experimental.20250409
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/api.js +97 -29
- package/lib/api/fetcher.js +31 -27
- package/lib/api/schemas.js +6 -0
- package/lib/auth/auth.js +127 -96
- package/lib/auth/keychain.js +82 -43
- package/lib/build/server/generate-server-entry.js +6 -6
- package/lib/build.js +2 -2
- package/lib/commands/build/build-javascript.js +1 -1
- package/lib/commands/build/validate-typescript.js +1 -1
- package/lib/commands/build.js +2 -2
- package/lib/commands/dev/boot.js +8 -8
- package/lib/commands/dev/bundle-javascript.js +1 -1
- package/lib/commands/dev/prepare-build-contexts.js +1 -1
- package/lib/commands/dev/upload.js +1 -18
- package/lib/commands/dev.js +5 -4
- package/lib/commands/init/create-project.js +7 -39
- package/lib/commands/init.js +6 -14
- package/lib/commands/login.js +8 -2
- package/lib/commands/logout.js +8 -2
- package/lib/commands/version/create/bundle-javascript.js +3 -3
- package/lib/commands/version/create.js +11 -11
- package/lib/commands/version/list.js +4 -4
- package/lib/commands/whoami.js +5 -6
- package/lib/errors.js +1 -0
- package/lib/print-errors.js +165 -0
- package/lib/spinners/determine-workspace.spinner.js +1 -24
- package/lib/spinners/get-app-slug-from-package-json.js +1 -20
- package/lib/util/copy-with-replace.js +2 -2
- package/lib/util/create-directory.js +1 -1
- package/lib/util/load-attio-cli-version.js +1 -26
- package/lib/util/upload-bundle.js +1 -1
- package/package.json +1 -1
- package/lib/auth/ensure-authed.js +0 -14
- package/lib/commands/dev/start-graphql-server.js +0 -32
- package/lib/commands/init/ask-language.js +0 -11
- package/lib/templates/javascript/.env +0 -12
- package/lib/templates/javascript/eslint.config.js +0 -48
- package/lib/templates/javascript/package.json +0 -26
- package/lib/templates/javascript/src/assets/icon.png +0 -0
- package/lib/templates/javascript/src/cat-fact.jsx +0 -16
- package/lib/templates/javascript/src/get-cat-fact.server.js +0 -6
- package/lib/templates/javascript/src/hello-world-action.jsx +0 -17
- package/lib/templates/javascript/src/hello-world-dialog.jsx +0 -26
- package/lib/templates/typescript/.eslintignore +0 -3
- package/lib/templates/typescript/src/assets/icon.png +0 -0
- /package/lib/{templates/typescript → template}/.env +0 -0
- /package/lib/{templates/javascript → template}/.eslintignore +0 -0
- /package/lib/{templates/common → template}/README.md +0 -0
- /package/lib/{templates/typescript → template}/eslint.config.js +0 -0
- /package/lib/{templates/typescript → template}/package.json +0 -0
- /package/lib/{templates/common → template}/src/assets/icon.png +0 -0
- /package/lib/{templates/typescript → template}/src/cat-fact.tsx +0 -0
- /package/lib/{templates/typescript → template}/src/get-cat-fact.server.ts +0 -0
- /package/lib/{templates/typescript → template}/src/hello-world-action.tsx +0 -0
- /package/lib/{templates/typescript → template}/src/hello-world-dialog.tsx +0 -0
- /package/lib/{templates/typescript → template}/tsconfig.json +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { glob } from "glob";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { errored, complete, isErrored, combineAsync } from "@attio/fetchable";
|
|
4
|
-
async function
|
|
4
|
+
async function findServerFunctionModules(cwd, pattern) {
|
|
5
5
|
try {
|
|
6
|
-
return complete(await glob(`**/*.${pattern}.
|
|
6
|
+
return complete(await glob(`**/*.${pattern}.{js,ts}`, { nodir: true, cwd }));
|
|
7
7
|
}
|
|
8
8
|
catch (error) {
|
|
9
9
|
return errored({
|
|
10
10
|
code: "ERROR_FINDING_SERVER_FUNCTION_MODULES",
|
|
11
|
-
|
|
11
|
+
path: cwd,
|
|
12
12
|
pattern,
|
|
13
13
|
error,
|
|
14
14
|
});
|
|
@@ -16,9 +16,9 @@ async function findPaths(dir, pattern) {
|
|
|
16
16
|
}
|
|
17
17
|
export async function generateServerEntry({ srcDirAbsolute, webhooksDirAbsolute, eventDirAbsolute, log, }) {
|
|
18
18
|
const pathsResult = await combineAsync([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
findServerFunctionModules(srcDirAbsolute, "server"),
|
|
20
|
+
findServerFunctionModules(webhooksDirAbsolute, "webhook"),
|
|
21
|
+
findServerFunctionModules(eventDirAbsolute, "event"),
|
|
22
22
|
]);
|
|
23
23
|
if (isErrored(pathsResult)) {
|
|
24
24
|
return pathsResult;
|
package/lib/build.js
CHANGED
|
@@ -13,6 +13,6 @@ const jsErrorSchema = z.object({
|
|
|
13
13
|
}),
|
|
14
14
|
});
|
|
15
15
|
export const errorsAndWarningsSchema = z.object({
|
|
16
|
-
errors: z.array(jsErrorSchema).optional(),
|
|
17
|
-
warnings: z.array(jsErrorSchema).optional(),
|
|
16
|
+
errors: z.array(jsErrorSchema).optional().readonly(),
|
|
17
|
+
warnings: z.array(jsErrorSchema).optional().readonly(),
|
|
18
18
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { prepareBuildContexts, } from "../dev/prepare-build-contexts.js";
|
|
2
1
|
import { combineAsync, complete, isErrored } from "@attio/fetchable";
|
|
2
|
+
import { prepareBuildContexts } from "../dev/prepare-build-contexts.js";
|
|
3
3
|
export async function buildJavaScript() {
|
|
4
4
|
const buildContextsResult = await prepareBuildContexts("write-to-disk");
|
|
5
5
|
if (isErrored(buildContextsResult)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { getDiagnostics, readConfig, typeScriptErrorSchema
|
|
2
|
+
import { getDiagnostics, readConfig, typeScriptErrorSchema } from "../../util/typescript.js";
|
|
3
3
|
import { complete, errored } from "@attio/fetchable";
|
|
4
4
|
export async function validateTypeScript() {
|
|
5
5
|
try {
|
package/lib/commands/build.js
CHANGED
|
@@ -24,8 +24,8 @@ export const build = new Command("build")
|
|
|
24
24
|
if (isErrored(jsResult)) {
|
|
25
25
|
if (jsResult.error.code === "BUILD_JAVASCRIPT_ERROR") {
|
|
26
26
|
const { errors, warnings } = jsResult.error;
|
|
27
|
-
errors
|
|
28
|
-
warnings
|
|
27
|
+
errors?.forEach((error) => printJsError(error, "error"));
|
|
28
|
+
warnings?.forEach((warning) => printJsError(warning, "warning"));
|
|
29
29
|
process.stderr.write("JavaScript build failed");
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
package/lib/commands/dev/boot.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getAppSlugFromPackageJson, printPackageJsonError, } from "../../spinners/get-app-slug-from-package-json.js";
|
|
2
|
-
import { determineWorkspace, printDetermineWorkspaceError, } from "../../spinners/determine-workspace.spinner.js";
|
|
3
|
-
import { getAppInfo } from "../../spinners/get-app-info.spinner.js";
|
|
4
|
-
import { loadEnv } from "../../util/load-env.js";
|
|
5
|
-
import { printFetcherError } from "../../api/fetcher.js";
|
|
6
1
|
import { isErrored } from "@attio/fetchable";
|
|
7
|
-
import {
|
|
2
|
+
import { printFetcherError, printCliVersionError, printPackageJsonError, printDetermineWorkspaceError, } from "../../print-errors.js";
|
|
3
|
+
import { getAppSlugFromPackageJson } from "../../spinners/get-app-slug-from-package-json.js";
|
|
4
|
+
import { determineWorkspace } from "../../spinners/determine-workspace.spinner.js";
|
|
5
|
+
import { loadAttioCliVersion } from "../../util/load-attio-cli-version.js";
|
|
8
6
|
import { API } from "../../api/api.js";
|
|
7
|
+
import { getAppInfo } from "../../spinners/get-app-info.spinner.js";
|
|
8
|
+
import { loadEnv } from "../../util/load-env.js";
|
|
9
9
|
export async function boot({ workspaceSlug }) {
|
|
10
10
|
const appSlugResult = await getAppSlugFromPackageJson();
|
|
11
11
|
if (isErrored(appSlugResult)) {
|
|
@@ -15,7 +15,7 @@ export async function boot({ workspaceSlug }) {
|
|
|
15
15
|
const appSlug = appSlugResult.value;
|
|
16
16
|
const appInfoResult = await getAppInfo(appSlug);
|
|
17
17
|
if (isErrored(appInfoResult)) {
|
|
18
|
-
printFetcherError("Error loading app info", appInfoResult.error
|
|
18
|
+
printFetcherError("Error loading app info", appInfoResult.error);
|
|
19
19
|
process.exit(1);
|
|
20
20
|
}
|
|
21
21
|
const appInfo = appInfoResult.value;
|
|
@@ -39,7 +39,7 @@ export async function boot({ workspaceSlug }) {
|
|
|
39
39
|
environmentVariables,
|
|
40
40
|
});
|
|
41
41
|
if (isErrored(devVersionResult)) {
|
|
42
|
-
printFetcherError("Error creating dev version", devVersionResult.error
|
|
42
|
+
printFetcherError("Error creating dev version", devVersionResult.error);
|
|
43
43
|
process.exit(1);
|
|
44
44
|
}
|
|
45
45
|
const devVersion = devVersionResult.value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import chokidar from "chokidar";
|
|
2
|
-
import { prepareBuildContexts, } from "./prepare-build-contexts.js";
|
|
3
2
|
import { combineAsync, complete, isErrored } from "@attio/fetchable";
|
|
3
|
+
import { prepareBuildContexts } from "./prepare-build-contexts.js";
|
|
4
4
|
export function bundleJavaScript(onSuccess, onError) {
|
|
5
5
|
const watcher = chokidar.watch(["./src/**/*.{js,jsx,ts,tsx}"], {
|
|
6
6
|
ignored: ["**/node_modules/**", "**/dist/**", "**/*.graphql.d.ts", "**/*.gql.d.ts"],
|
|
@@ -3,7 +3,7 @@ import tmp from "tmp-promise";
|
|
|
3
3
|
import fs from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { createClientBuildConfig } from "../../build/client/create-client-build-config.js";
|
|
6
|
-
import { generateClientEntry
|
|
6
|
+
import { generateClientEntry } from "../../build/client/generate-client-entry.js";
|
|
7
7
|
import { createServerBuildConfig } from "../../build/server/create-server-build-config.js";
|
|
8
8
|
import { generateServerEntry } from "../../build/server/generate-server-entry.js";
|
|
9
9
|
import { errored, isErrored, complete, combineAsync } from "@attio/fetchable";
|
|
@@ -2,9 +2,7 @@ import notifier from "node-notifier";
|
|
|
2
2
|
import { spinnerify } from "../../util/spinner.js";
|
|
3
3
|
import { uploadBundle } from "../../util/upload-bundle.js";
|
|
4
4
|
import { API } from "../../api/api.js";
|
|
5
|
-
import { isErrored,
|
|
6
|
-
import { printFetcherError } from "../../api/fetcher.js";
|
|
7
|
-
import chalk from "chalk";
|
|
5
|
+
import { isErrored, complete, combineAsync } from "@attio/fetchable";
|
|
8
6
|
export async function upload({ contents, devVersionId, appId, }) {
|
|
9
7
|
return await spinnerify("Uploading...", () => `Upload complete at ${new Date().toLocaleTimeString()}`, async () => {
|
|
10
8
|
const startUploadResult = await API.startUpload({
|
|
@@ -38,18 +36,3 @@ export async function upload({ contents, devVersionId, appId, }) {
|
|
|
38
36
|
return complete(undefined);
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
|
-
export function printUploadError(error) {
|
|
42
|
-
switch (error.code) {
|
|
43
|
-
case "BUNDLE_UPLOAD_ERROR":
|
|
44
|
-
process.stderr.write(chalk.red(`Error uploading bundle: ${error.error}\n`));
|
|
45
|
-
break;
|
|
46
|
-
case "START_UPLOAD_ERROR":
|
|
47
|
-
printFetcherError("Error starting upload", error.fetcherError);
|
|
48
|
-
break;
|
|
49
|
-
case "COMPLETE_BUNDLE_UPLOAD_ERROR":
|
|
50
|
-
printFetcherError("Error completing bundle upload", error.fetcherError);
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
return error;
|
|
54
|
-
}
|
|
55
|
-
}
|
package/lib/commands/dev.js
CHANGED
|
@@ -8,10 +8,11 @@ import { bundleJavaScript } from "./dev/bundle-javascript.js";
|
|
|
8
8
|
import { boot } from "./dev/boot.js";
|
|
9
9
|
import { onboarding } from "./dev/onboarding.js";
|
|
10
10
|
import { graphqlServer } from "./dev/graphql-server.js";
|
|
11
|
-
import { printUploadError
|
|
11
|
+
import { printUploadError } from "../print-errors.js";
|
|
12
|
+
import { upload } from "./dev/upload.js";
|
|
12
13
|
import { isErrored } from "@attio/fetchable";
|
|
13
14
|
import { printJsError, printTsError } from "../util/typescript.js";
|
|
14
|
-
import { printBuildContextError
|
|
15
|
+
import { printBuildContextError } from "./dev/prepare-build-contexts.js";
|
|
15
16
|
import notifier from "node-notifier";
|
|
16
17
|
const notifyTsErrors = (errors) => {
|
|
17
18
|
notifier.notify({
|
|
@@ -92,8 +93,8 @@ export const dev = new Command("dev")
|
|
|
92
93
|
if (error.code === "BUILD_JAVASCRIPT_ERROR") {
|
|
93
94
|
notifyJsErrors(error);
|
|
94
95
|
const { errors, warnings } = error;
|
|
95
|
-
errors
|
|
96
|
-
warnings
|
|
96
|
+
errors?.forEach((error) => printJsError(error, "error"));
|
|
97
|
+
warnings?.forEach((warning) => printJsError(warning, "warning"));
|
|
97
98
|
}
|
|
98
99
|
else {
|
|
99
100
|
printBuildContextError(error);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { fileURLToPath } from "url";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import chalk from "chalk";
|
|
4
3
|
import { existsSync } from "fs";
|
|
5
4
|
import { createDirectory } from "../../util/create-directory.js";
|
|
6
5
|
import { canWrite } from "../../util/can-write.js";
|
|
7
6
|
import { copyWithTransform } from "../../util/copy-with-replace.js";
|
|
8
7
|
import { spinnerify } from "../../util/spinner.js";
|
|
9
|
-
import {
|
|
10
|
-
export async function createProject({ appSlug,
|
|
8
|
+
import { complete, errored, isErrored } from "@attio/fetchable";
|
|
9
|
+
export async function createProject({ appSlug, appInfo, }) {
|
|
11
10
|
return await spinnerify("Creating project...", "Project created", async () => {
|
|
12
11
|
const cwd = process.cwd();
|
|
13
12
|
const projectPath = path.join(cwd, appSlug);
|
|
@@ -15,7 +14,7 @@ export async function createProject({ appSlug, language, appInfo, }) {
|
|
|
15
14
|
return errored({ code: "DIRECTORY_ALREADY_EXISTS", path: projectPath });
|
|
16
15
|
}
|
|
17
16
|
if (!canWrite(cwd)) {
|
|
18
|
-
return errored({ code: "WRITE_ACCESS_DENIED",
|
|
17
|
+
return errored({ code: "WRITE_ACCESS_DENIED", path: cwd });
|
|
19
18
|
}
|
|
20
19
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
20
|
const projectDirResult = await createDirectory(appSlug);
|
|
@@ -23,46 +22,15 @@ export async function createProject({ appSlug, language, appInfo, }) {
|
|
|
23
22
|
return projectDirResult;
|
|
24
23
|
}
|
|
25
24
|
const projectDir = projectDirResult.value;
|
|
26
|
-
const
|
|
27
|
-
const commonDir = path.resolve(__dirname, "../../templates", "common");
|
|
25
|
+
const templateDir = path.resolve(__dirname, "../../template");
|
|
28
26
|
const transform = (contents) => contents
|
|
29
27
|
.replaceAll("title-to-be-replaced", appInfo.title)
|
|
30
28
|
.replaceAll("id-to-be-replaced", appInfo.app_id)
|
|
31
29
|
.replaceAll("slug-to-be-replaced", appSlug);
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]);
|
|
36
|
-
if (isErrored(results)) {
|
|
37
|
-
return results;
|
|
30
|
+
const result = await copyWithTransform(templateDir, projectDir, transform);
|
|
31
|
+
if (isErrored(result)) {
|
|
32
|
+
return result;
|
|
38
33
|
}
|
|
39
34
|
return complete(undefined);
|
|
40
35
|
});
|
|
41
36
|
}
|
|
42
|
-
export function printCreateProjectError(error) {
|
|
43
|
-
switch (error.code) {
|
|
44
|
-
case "DIRECTORY_ALREADY_EXISTS":
|
|
45
|
-
process.stderr.write(chalk.red(`Directory ${error.path} already exists`));
|
|
46
|
-
break;
|
|
47
|
-
case "WRITE_ACCESS_DENIED":
|
|
48
|
-
process.stderr.write(chalk.red(`Write access denied to ${error.directory}`));
|
|
49
|
-
break;
|
|
50
|
-
case "FAILED_TO_CREATE_DIRECTORY":
|
|
51
|
-
process.stderr.write(chalk.red(`Failed to create directory ${error.directory}`));
|
|
52
|
-
break;
|
|
53
|
-
case "FAILED_TO_COPY_FILE":
|
|
54
|
-
process.stderr.write(chalk.red(`Failed to copy file ${error.src} to ${error.dest}`));
|
|
55
|
-
break;
|
|
56
|
-
case "FAILED_TO_LIST_FILES":
|
|
57
|
-
process.stderr.write(chalk.red(`Failed to list files in ${error.directory}`));
|
|
58
|
-
break;
|
|
59
|
-
case "FAILED_TO_READ_FILE":
|
|
60
|
-
process.stderr.write(chalk.red(`Failed to read file ${error.path}`));
|
|
61
|
-
break;
|
|
62
|
-
case "FAILED_TO_WRITE_FILE":
|
|
63
|
-
process.stderr.write(chalk.red(`Failed to write file ${error.path}`));
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
return error;
|
|
67
|
-
}
|
|
68
|
-
}
|
package/lib/commands/init.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
import { Argument, Command
|
|
1
|
+
import { Argument, Command } from "commander";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { createProject
|
|
5
|
-
import {
|
|
4
|
+
import { createProject } from "./init/create-project.js";
|
|
5
|
+
import { printCreateProjectError, printFetcherError } from "../print-errors.js";
|
|
6
6
|
import { printLogo } from "../util/print-logo.js";
|
|
7
7
|
import { getAppInfo } from "../spinners/get-app-info.spinner.js";
|
|
8
|
-
import { printFetcherError } from "../api/fetcher.js";
|
|
9
8
|
import { isErrored } from "@attio/fetchable";
|
|
10
9
|
import boxen from "boxen";
|
|
11
10
|
export const argsSchema = z.string();
|
|
12
|
-
export const optionsSchema = z.object({
|
|
13
|
-
language: z.enum(["javascript", "typescript"]).optional(),
|
|
14
|
-
});
|
|
15
11
|
export const init = new Command("init")
|
|
16
12
|
.description("Initialize a new Attio app")
|
|
17
13
|
.addArgument(new Argument("<app-slug>", "The app slug, chosen in the developer dashboard"))
|
|
18
|
-
.
|
|
19
|
-
.action(async (unparsedArgs, unparsedOptions) => {
|
|
14
|
+
.action(async (unparsedArgs) => {
|
|
20
15
|
try {
|
|
21
16
|
printLogo();
|
|
22
17
|
const appSlug = argsSchema.parse(unparsedArgs);
|
|
23
|
-
const { language: cliLanguage } = optionsSchema.parse(unparsedOptions);
|
|
24
18
|
const appInfoResult = await getAppInfo(appSlug);
|
|
25
19
|
if (isErrored(appInfoResult)) {
|
|
26
|
-
printFetcherError("Failed to fetch app info", appInfoResult.error
|
|
20
|
+
printFetcherError("Failed to fetch app info", appInfoResult.error);
|
|
27
21
|
process.exit(1);
|
|
28
22
|
}
|
|
29
23
|
const appInfo = appInfoResult.value;
|
|
30
|
-
const language = cliLanguage ?? (await askLanguage());
|
|
31
24
|
const result = await createProject({
|
|
32
25
|
appSlug,
|
|
33
|
-
language,
|
|
34
26
|
appInfo,
|
|
35
27
|
});
|
|
36
28
|
if (isErrored(result)) {
|
|
@@ -52,7 +44,7 @@ ${boxen(`cd ${appSlug}\nnpm install\nnpm run dev`, {
|
|
|
52
44
|
process.exit(0);
|
|
53
45
|
}
|
|
54
46
|
catch (error) {
|
|
55
|
-
process.stderr.write(chalk.red(
|
|
47
|
+
process.stderr.write(`${chalk.red(`✖ ${error}`)}\n`);
|
|
56
48
|
process.exit(1);
|
|
57
49
|
}
|
|
58
50
|
});
|
package/lib/commands/login.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { Authenticator } from "../auth/auth.js";
|
|
3
|
+
import { isErrored } from "@attio/fetchable";
|
|
4
|
+
import { printAuthenticationError } from "../print-errors.js";
|
|
3
5
|
export const login = new Command("login")
|
|
4
6
|
.description("Authenticate with Attio")
|
|
5
7
|
.action(async () => {
|
|
6
|
-
await
|
|
8
|
+
const result = await Authenticator.authenticate();
|
|
9
|
+
if (isErrored(result)) {
|
|
10
|
+
printAuthenticationError(result.error);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
7
13
|
process.stdout.write("🔓 Successfully authenticated.\n");
|
|
8
14
|
process.exit(0);
|
|
9
15
|
});
|
package/lib/commands/logout.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { Keychain } from "../auth/keychain.js";
|
|
3
|
+
import { printKeychainError } from "../print-errors.js";
|
|
4
|
+
import { isErrored } from "@attio/fetchable";
|
|
3
5
|
export const logout = new Command("logout").description("Log out from Attio").action(async () => {
|
|
4
|
-
await
|
|
6
|
+
const result = await Keychain.delete();
|
|
7
|
+
if (isErrored(result)) {
|
|
8
|
+
printKeychainError(result.error);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
5
11
|
process.stdout.write("🔒 Successfully logged out.\n");
|
|
6
12
|
process.exit(0);
|
|
7
13
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { complete, isErrored, errored, combineAsync } from "@attio/fetchable";
|
|
2
|
-
import { prepareBuildContexts
|
|
2
|
+
import { prepareBuildContexts } from "../../dev/prepare-build-contexts.js";
|
|
3
3
|
export async function bundleJavaScript() {
|
|
4
4
|
const buildContextsResult = await prepareBuildContexts("in-memory");
|
|
5
5
|
if (isErrored(buildContextsResult)) {
|
|
6
6
|
return errored({
|
|
7
7
|
code: "ERROR_PREPARING_BUILD_CONTEXT",
|
|
8
|
-
|
|
8
|
+
error: buildContextsResult.error,
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
const buildContexts = buildContextsResult.value;
|
|
@@ -21,7 +21,7 @@ export async function bundleJavaScript() {
|
|
|
21
21
|
if (isErrored(disposeResults)) {
|
|
22
22
|
return errored({
|
|
23
23
|
code: "ERROR_DISPOSING_BUILD_CONTEXT",
|
|
24
|
-
|
|
24
|
+
error: disposeResults.error,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
return complete(bundles);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { spinnerify } from "../../util/spinner.js";
|
|
4
|
-
import { loadAttioCliVersion
|
|
4
|
+
import { loadAttioCliVersion } from "../../util/load-attio-cli-version.js";
|
|
5
5
|
import { uploadBundle } from "../../util/upload-bundle.js";
|
|
6
6
|
import { getVersions } from "../../spinners/get-versions.spinner.js";
|
|
7
7
|
import { getAppInfo } from "../../spinners/get-app-info.spinner.js";
|
|
8
|
-
import { printFetcherError } from "../../
|
|
8
|
+
import { printCliVersionError, printFetcherError, printPackageJsonError } from "../../print-errors.js";
|
|
9
9
|
import { combineAsync, isErrored } from "@attio/fetchable";
|
|
10
|
-
import { getAppSlugFromPackageJson
|
|
10
|
+
import { getAppSlugFromPackageJson } from "../../spinners/get-app-slug-from-package-json.js";
|
|
11
11
|
import { bundleJavaScript } from "./create/bundle-javascript.js";
|
|
12
12
|
import { printBuildContextError } from "../dev/prepare-build-contexts.js";
|
|
13
13
|
import { API } from "../../api/api.js";
|
|
@@ -23,7 +23,7 @@ export const versionCreate = new Command("create")
|
|
|
23
23
|
const appSlug = appSlugResult.value;
|
|
24
24
|
const appInfoResult = await getAppInfo(appSlug);
|
|
25
25
|
if (isErrored(appInfoResult)) {
|
|
26
|
-
printFetcherError("Error loading app info", appInfoResult.error
|
|
26
|
+
printFetcherError("Error loading app info", appInfoResult.error);
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
29
|
const appInfo = appInfoResult.value;
|
|
@@ -33,22 +33,22 @@ export const versionCreate = new Command("create")
|
|
|
33
33
|
const { error } = bundleResult.error;
|
|
34
34
|
if (error.code === "BUILD_JAVASCRIPT_ERROR") {
|
|
35
35
|
const { errors, warnings } = error;
|
|
36
|
-
errors
|
|
37
|
-
warnings
|
|
36
|
+
errors?.forEach((error) => printJsError(error, "error"));
|
|
37
|
+
warnings?.forEach((warning) => printJsError(warning, "warning"));
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
printBuildContextError(error);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
printBuildContextError(bundleResult.error.
|
|
44
|
+
printBuildContextError(bundleResult.error.error);
|
|
45
45
|
}
|
|
46
46
|
process.exit(1);
|
|
47
47
|
}
|
|
48
48
|
const [clientBundle, serverBundle] = bundleResult.value;
|
|
49
49
|
const versionsResult = await getVersions(appInfo);
|
|
50
50
|
if (isErrored(versionsResult)) {
|
|
51
|
-
printFetcherError("Error fetching versions", versionsResult.error
|
|
51
|
+
printFetcherError("Error fetching versions", versionsResult.error);
|
|
52
52
|
process.exit(1);
|
|
53
53
|
}
|
|
54
54
|
const versions = versionsResult.value;
|
|
@@ -67,7 +67,7 @@ export const versionCreate = new Command("create")
|
|
|
67
67
|
cliVersion,
|
|
68
68
|
});
|
|
69
69
|
if (isErrored(versionResult)) {
|
|
70
|
-
printFetcherError("Error creating version", versionResult.error
|
|
70
|
+
printFetcherError("Error creating version", versionResult.error);
|
|
71
71
|
process.exit(1);
|
|
72
72
|
}
|
|
73
73
|
const { client_bundle_upload_url, server_bundle_upload_url } = versionResult.value;
|
|
@@ -76,7 +76,7 @@ export const versionCreate = new Command("create")
|
|
|
76
76
|
uploadBundle(serverBundle, server_bundle_upload_url),
|
|
77
77
|
]);
|
|
78
78
|
if (isErrored(uploadResult)) {
|
|
79
|
-
process.stderr.write(`${chalk.red("✖ ")}Failed to upload bundle to: ${uploadResult.error.
|
|
79
|
+
process.stderr.write(`${chalk.red("✖ ")}Failed to upload bundle to: ${uploadResult.error.upload_url}\n`);
|
|
80
80
|
process.exit(1);
|
|
81
81
|
}
|
|
82
82
|
return versionResult;
|
|
@@ -93,7 +93,7 @@ export const versionCreate = new Command("create")
|
|
|
93
93
|
bundleId: version.app_prod_version_bundle_id,
|
|
94
94
|
}));
|
|
95
95
|
if (isErrored(signingResult)) {
|
|
96
|
-
printFetcherError("Error signing bundles", signingResult.error
|
|
96
|
+
printFetcherError("Error signing bundles", signingResult.error);
|
|
97
97
|
process.exit(1);
|
|
98
98
|
}
|
|
99
99
|
process.stdout.write(`\nVersion ${chalk.green(`${version.major}.${version.minor}`)} created!\n\n`);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { getAppInfo } from "../../spinners/get-app-info.spinner.js";
|
|
3
|
-
import { getAppSlugFromPackageJson
|
|
3
|
+
import { getAppSlugFromPackageJson } from "../../spinners/get-app-slug-from-package-json.js";
|
|
4
4
|
import { getVersions } from "../../spinners/get-versions.spinner.js";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import Table from "cli-table3";
|
|
7
7
|
import { format as formatDate } from "date-fns";
|
|
8
8
|
import { isErrored } from "@attio/fetchable";
|
|
9
|
-
import { printFetcherError } from "../../
|
|
9
|
+
import { printFetcherError, printPackageJsonError } from "../../print-errors.js";
|
|
10
10
|
export const versionList = new Command()
|
|
11
11
|
.name("list")
|
|
12
12
|
.description("List all versions of your app")
|
|
@@ -19,13 +19,13 @@ export const versionList = new Command()
|
|
|
19
19
|
const appSlug = appSlugResult.value;
|
|
20
20
|
const appInfoResult = await getAppInfo(appSlug);
|
|
21
21
|
if (isErrored(appInfoResult)) {
|
|
22
|
-
printFetcherError("Error loading app info", appInfoResult.error
|
|
22
|
+
printFetcherError("Error loading app info", appInfoResult.error);
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
const appInfo = appInfoResult.value;
|
|
26
26
|
const versionsResult = await getVersions(appInfo);
|
|
27
27
|
if (isErrored(versionsResult)) {
|
|
28
|
-
printFetcherError("Error loading versions", versionsResult.error
|
|
28
|
+
printFetcherError("Error loading versions", versionsResult.error);
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
const versions = versionsResult.value;
|
package/lib/commands/whoami.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { Keychain } from "../auth/keychain.js";
|
|
3
3
|
import { API } from "../api/api.js";
|
|
4
4
|
import { isErrored } from "@attio/fetchable";
|
|
5
|
-
import { printFetcherError } from "../
|
|
5
|
+
import { printFetcherError } from "../print-errors.js";
|
|
6
6
|
export const whoami = new Command()
|
|
7
7
|
.name("whoami")
|
|
8
8
|
.description("Identify the current user")
|
|
9
9
|
.action(async () => {
|
|
10
|
-
const tokenResult = await
|
|
11
|
-
if (
|
|
10
|
+
const tokenResult = await Keychain.load();
|
|
11
|
+
if (isErrored(tokenResult) || tokenResult.value === null) {
|
|
12
12
|
process.stdout.write("🔒 Not logged in.\n");
|
|
13
13
|
process.exit(0);
|
|
14
14
|
}
|
|
15
15
|
const result = await API.whoami();
|
|
16
16
|
if (isErrored(result)) {
|
|
17
|
-
|
|
18
|
-
printFetcherError("Error fetching user", fetcherError);
|
|
17
|
+
printFetcherError("Error fetching user", result.error);
|
|
19
18
|
process.exit(1);
|
|
20
19
|
}
|
|
21
20
|
const { name, email_address } = result.value;
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|