attio 0.0.1-experimental.20251002 → 0.0.1-experimental.20251003.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.
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { Project } from "ts-morph";
|
|
4
4
|
import { complete, errored, fromPromise, isComplete } from "@attio/fetchable-npm";
|
|
5
5
|
import { APP_SETTINGS_FILENAME } from "../../constants/settings-files.js";
|
|
6
|
-
import {
|
|
6
|
+
import { USE_SETTINGS } from "../../env.js";
|
|
7
7
|
import { getAppEntryPoint } from "../../util/get-app-entry-point.js";
|
|
8
8
|
const ASSET_FILE_EXTENSIONS = ["png"];
|
|
9
9
|
export async function generateClientEntry({ srcDirAbsolute, assetsDirAbsolute, }) {
|
|
@@ -84,7 +84,7 @@ export async function generateClientEntry({ srcDirAbsolute, assetsDirAbsolute, }
|
|
|
84
84
|
${importAppJS}
|
|
85
85
|
${importAssetsJS}
|
|
86
86
|
|
|
87
|
-
${
|
|
87
|
+
${USE_SETTINGS ? initSettingsJS : ""}
|
|
88
88
|
|
|
89
89
|
${registerSurfacesJS}
|
|
90
90
|
|
package/lib/commands/dev.js
CHANGED
|
@@ -4,8 +4,10 @@ import notifier from "node-notifier";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { isErrored } from "@attio/fetchable-npm";
|
|
6
6
|
import { authenticator } from "../auth/auth.js";
|
|
7
|
+
import { HIDDEN_ATTIO_DIRECTORY } from "../constants/hidden-attio-directory.js";
|
|
7
8
|
import { USE_APP_TS, USE_SETTINGS } from "../env.js";
|
|
8
9
|
import { printUploadError } from "../print-errors.js";
|
|
10
|
+
import { addAttioHiddenDirectoryToTsConfig } from "../util/add-attio-hidden-directory-to-ts-config.js";
|
|
9
11
|
import { ensureAppEntryPoint } from "../util/ensure-app-entry-point.js";
|
|
10
12
|
import { generateGitignore } from "../util/generate-gitignore.js";
|
|
11
13
|
import { generateSettingsFiles } from "../util/generate-settings-files.js";
|
|
@@ -64,6 +66,19 @@ export const dev = new Command("dev")
|
|
|
64
66
|
}
|
|
65
67
|
await generateGitignore();
|
|
66
68
|
if (USE_SETTINGS) {
|
|
69
|
+
const updateTsconfigResult = await addAttioHiddenDirectoryToTsConfig();
|
|
70
|
+
if (isErrored(updateTsconfigResult)) {
|
|
71
|
+
switch (updateTsconfigResult.error.code) {
|
|
72
|
+
case "TS_CONFIG_NOT_FOUND":
|
|
73
|
+
case "FAILED_TO_READ_TSCONFIG":
|
|
74
|
+
case "FAILED_TO_PARSE_TSCONFIG":
|
|
75
|
+
case "FAILED_TO_WRITE_TSCONFIG":
|
|
76
|
+
process.stderr.write(chalk.yellow(`Failed to update tsconfig. Make sure the "include" field contains the ${HIDDEN_ATTIO_DIRECTORY} directory \n`));
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(updateTsconfigResult.error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
67
82
|
const generateResult = await generateSettingsFiles();
|
|
68
83
|
if (isErrored(generateResult)) {
|
|
69
84
|
hardExit("Failed to generate settings files");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const HIDDEN_ATTIO_DIRECTORY = "
|
|
1
|
+
export const HIDDEN_ATTIO_DIRECTORY = ".attio";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { complete, errored, fromPromise, fromThrowable, isErrored } from "@attio/fetchable-npm";
|
|
5
|
+
import { HIDDEN_ATTIO_DIRECTORY } from "../constants/hidden-attio-directory.js";
|
|
6
|
+
const tsconfigSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
include: z.array(z.string()),
|
|
9
|
+
})
|
|
10
|
+
.passthrough();
|
|
11
|
+
export async function addAttioHiddenDirectoryToTsConfig() {
|
|
12
|
+
const tsconfigPath = path.resolve("./tsconfig.json");
|
|
13
|
+
const tsconfigContentResult = await fromPromise(fs.readFile(tsconfigPath, "utf-8"));
|
|
14
|
+
if (isErrored(tsconfigContentResult)) {
|
|
15
|
+
const { error } = tsconfigContentResult;
|
|
16
|
+
if (typeof error === "object" &&
|
|
17
|
+
error !== null &&
|
|
18
|
+
"code" in error &&
|
|
19
|
+
error.code === "ENOENT") {
|
|
20
|
+
return errored({ code: "TS_CONFIG_NOT_FOUND" });
|
|
21
|
+
}
|
|
22
|
+
return errored({ code: "FAILED_TO_READ_TSCONFIG" });
|
|
23
|
+
}
|
|
24
|
+
const tsconfigResult = fromThrowable(() => tsconfigSchema.parse(JSON.parse(tsconfigContentResult.value)));
|
|
25
|
+
if (isErrored(tsconfigResult)) {
|
|
26
|
+
return errored({ code: "FAILED_TO_PARSE_TSCONFIG" });
|
|
27
|
+
}
|
|
28
|
+
if (tsconfigResult.value.include.includes(HIDDEN_ATTIO_DIRECTORY)) {
|
|
29
|
+
return complete(false);
|
|
30
|
+
}
|
|
31
|
+
const updatedTsconfig = {
|
|
32
|
+
...tsconfigResult.value,
|
|
33
|
+
include: [...tsconfigResult.value.include, HIDDEN_ATTIO_DIRECTORY],
|
|
34
|
+
};
|
|
35
|
+
const writeResult = await fromPromise(fs.writeFile(tsconfigPath, JSON.stringify(updatedTsconfig, null, 2)));
|
|
36
|
+
if (isErrored(writeResult)) {
|
|
37
|
+
return errored({ code: "FAILED_TO_WRITE_TSCONFIG" });
|
|
38
|
+
}
|
|
39
|
+
return complete(true);
|
|
40
|
+
}
|