create-tanejs 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eray
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # create-tanejs
2
+
3
+ Scaffold a [tane](https://www.npmjs.com/package/tane) app — a file-system
4
+ router with nested layouts, loaders, metadata and SSR for
5
+ [Octane](https://octanejs.dev).
6
+
7
+ ```bash
8
+ npm create tanejs my-app
9
+ cd my-app
10
+ npm install
11
+ npm run dev
12
+ ```
13
+
14
+ ## What you get
15
+
16
+ ```
17
+ app/
18
+ layout.tsrx root layout, exports metadata
19
+ page.tsrx /
20
+ about/page.tsrx /about
21
+ not-found.tsrx 404
22
+ global.css Tailwind entry, picked up automatically
23
+ tane.config.ts optional
24
+ tsconfig.json
25
+ package.json
26
+ ```
27
+
28
+ Ten files, Tailwind wired up, routes in Octane's `.tsrx` syntax. No
29
+ `vite.config.ts`, no `index.html`, no server file — `tane dev`, `tane build` and
30
+ `tane start` handle those.
31
+
32
+ ## Flags
33
+
34
+ ```
35
+ npm create tanejs <directory>
36
+
37
+ --name <name> package name (default: the directory name)
38
+ -f, --force write into a directory that is not empty
39
+ -h, --help show this message
40
+ ```
41
+
42
+ ## License
43
+
44
+ MIT
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { run } from "../dist/index.js";
3
+
4
+ run(process.argv.slice(2));
@@ -0,0 +1,23 @@
1
+ import { type TemplateOptions } from "./template.js";
2
+ export { templateFiles, type TemplateOptions } from "./template.js";
3
+ export declare class CreateError extends Error {
4
+ readonly name = "CreateError";
5
+ }
6
+ export interface CreateArgs {
7
+ readonly directory: string;
8
+ readonly name?: string;
9
+ readonly force: boolean;
10
+ readonly help: boolean;
11
+ }
12
+ /** npm package names are lowercase and a short list of punctuation. */
13
+ export declare function toPackageName(directory: string): string;
14
+ export declare function parseArgs(argv: readonly string[]): CreateArgs;
15
+ /** A directory that does not exist, or exists with nothing but dotfiles in it. */
16
+ export declare function isWritableTarget(directory: string): boolean;
17
+ export interface ScaffoldOptions extends TemplateOptions {
18
+ readonly directory: string;
19
+ readonly force?: boolean;
20
+ }
21
+ export declare function scaffold(options: ScaffoldOptions): string[];
22
+ export declare const HELP = "create-tanejs \u2014 scaffold a tane app\n\nUsage\n npm create tanejs <directory>\n\nFlags\n --name <name> Package name (default: the directory name)\n -f, --force Write into a directory that is not empty\n -h, --help Show this message\n";
23
+ export declare function run(argv: readonly string[]): void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAEpE,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAkB,IAAI,iBAAiB;CACxC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAID,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAsC7D;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CAa3D;AAED,eAAO,MAAM,IAAI,gRAShB,CAAC;AAEF,wBAAgB,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAuCjD"}
package/dist/index.js ADDED
@@ -0,0 +1,121 @@
1
+ import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
2
+ import { basename, dirname, join, resolve } from "node:path";
3
+ import { templateFiles } from "./template.js";
4
+ export { templateFiles } from "./template.js";
5
+ export class CreateError extends Error {
6
+ name = "CreateError";
7
+ }
8
+ const NAME_PATTERN = /^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
9
+ /** npm package names are lowercase and a short list of punctuation. */
10
+ export function toPackageName(directory) {
11
+ const base = basename(resolve(directory))
12
+ .toLowerCase()
13
+ .replace(/[^a-z0-9-._~]+/g, "-")
14
+ .replace(/^[-._]+|[-._]+$/g, "");
15
+ return base === "" ? "tane-app" : base;
16
+ }
17
+ export function parseArgs(argv) {
18
+ let directory;
19
+ let name;
20
+ let force = false;
21
+ for (let index = 0; index < argv.length; index += 1) {
22
+ const arg = argv[index];
23
+ if (arg === "--help" || arg === "-h") {
24
+ return { directory: ".", force, help: true };
25
+ }
26
+ if (arg === "--force" || arg === "-f") {
27
+ force = true;
28
+ continue;
29
+ }
30
+ if (arg === "--name") {
31
+ index += 1;
32
+ name = argv[index];
33
+ if (name === undefined)
34
+ throw new CreateError("--name needs a package name.");
35
+ continue;
36
+ }
37
+ if (arg.startsWith("--name=")) {
38
+ name = arg.slice("--name=".length);
39
+ continue;
40
+ }
41
+ if (arg.startsWith("-")) {
42
+ throw new CreateError(`Unknown flag "${arg}". Run \`create-tanejs --help\`.`);
43
+ }
44
+ if (directory !== undefined)
45
+ throw new CreateError(`Unexpected argument "${arg}".`);
46
+ directory = arg;
47
+ }
48
+ if (directory === undefined) {
49
+ throw new CreateError("Which directory? Try `npm create tanejs my-app`.");
50
+ }
51
+ if (name !== undefined && !NAME_PATTERN.test(name)) {
52
+ throw new CreateError(`"${name}" is not a valid npm package name.`);
53
+ }
54
+ return { directory, force, help: false, ...(name === undefined ? {} : { name }) };
55
+ }
56
+ /** A directory that does not exist, or exists with nothing but dotfiles in it. */
57
+ export function isWritableTarget(directory) {
58
+ if (!existsSync(directory))
59
+ return true;
60
+ return readdirSync(directory).filter((entry) => !entry.startsWith(".")).length === 0;
61
+ }
62
+ export function scaffold(options) {
63
+ const target = resolve(options.directory);
64
+ if (options.force !== true && !isWritableTarget(target)) {
65
+ throw new CreateError(`"${target}" is not empty. Pass --force to write into it anyway.`);
66
+ }
67
+ const files = templateFiles(options);
68
+ for (const [relative, contents] of Object.entries(files)) {
69
+ const absolute = join(target, relative);
70
+ mkdirSync(dirname(absolute), { recursive: true });
71
+ writeFileSync(absolute, contents, "utf8");
72
+ }
73
+ return Object.keys(files).sort();
74
+ }
75
+ export const HELP = `create-tanejs — scaffold a tane app
76
+
77
+ Usage
78
+ npm create tanejs <directory>
79
+
80
+ Flags
81
+ --name <name> Package name (default: the directory name)
82
+ -f, --force Write into a directory that is not empty
83
+ -h, --help Show this message
84
+ `;
85
+ export function run(argv) {
86
+ let args;
87
+ try {
88
+ args = parseArgs(argv);
89
+ }
90
+ catch (error) {
91
+ process.stderr.write(`\n ${error.message}\n\n`);
92
+ process.exitCode = 1;
93
+ return;
94
+ }
95
+ if (args.help) {
96
+ process.stdout.write(HELP);
97
+ return;
98
+ }
99
+ try {
100
+ scaffold({
101
+ directory: args.directory,
102
+ name: args.name ?? toPackageName(args.directory),
103
+ force: args.force,
104
+ });
105
+ }
106
+ catch (error) {
107
+ process.stderr.write(`\n ${error.message}\n\n`);
108
+ process.exitCode = 1;
109
+ return;
110
+ }
111
+ process.stdout.write([
112
+ "",
113
+ ` Created ${resolve(args.directory)}`,
114
+ "",
115
+ ` cd ${args.directory}`,
116
+ " npm install",
117
+ " npm run dev",
118
+ "",
119
+ "",
120
+ ].join("\n"));
121
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAwB,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAwB,MAAM,eAAe,CAAC;AAEpE,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClB,IAAI,GAAG,aAAa,CAAC;CACxC;AASD,MAAM,YAAY,GAAG,0DAA0D,CAAC;AAEhF,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,MAAM,IAAI,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AC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAQ,KAAe,CAAC,OAAO,MAAM,CAAC,CAAC;QAC5D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB;QACE,EAAE;QACF,aAAa,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QACtC,EAAE;QACF,QAAQ,IAAI,CAAC,SAAS,EAAE;QACxB,eAAe;QACf,eAAe;QACf,EAAE;QACF,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface TemplateOptions {
2
+ /** The npm package name for the scaffolded app. */
3
+ readonly name: string;
4
+ /** Version range written for the `tanejs` dependency. */
5
+ readonly taneVersion?: string;
6
+ readonly octaneVersion?: string;
7
+ }
8
+ /**
9
+ * The files a new app is made of, as a path → contents map. Kept separate from
10
+ * disk writing so the shape of a scaffolded project can be asserted directly.
11
+ */
12
+ export declare function templateFiles(options: TemplateOptions): Record<string, string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAmID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAa9E"}
@@ -0,0 +1,151 @@
1
+ const DEFAULT_TANE = "^0.1.0";
2
+ const DEFAULT_OCTANE = "^0.1.17";
3
+ function packageJson(options) {
4
+ return `${JSON.stringify({
5
+ name: options.name,
6
+ private: true,
7
+ type: "module",
8
+ scripts: {
9
+ dev: "tane dev",
10
+ build: "tane build",
11
+ start: "tane start",
12
+ },
13
+ dependencies: {
14
+ octane: options.octaneVersion ?? DEFAULT_OCTANE,
15
+ tanejs: options.taneVersion ?? DEFAULT_TANE,
16
+ },
17
+ devDependencies: {
18
+ "@tailwindcss/vite": "^4.3.3",
19
+ tailwindcss: "^4.3.3",
20
+ typescript: "^5.7.0",
21
+ },
22
+ }, null, 2)}\n`;
23
+ }
24
+ const TSCONFIG = `${JSON.stringify({
25
+ compilerOptions: {
26
+ target: "ES2023",
27
+ lib: ["ES2023", "DOM", "DOM.Iterable"],
28
+ module: "ESNext",
29
+ moduleResolution: "bundler",
30
+ strict: true,
31
+ noEmit: true,
32
+ jsx: "react-jsx",
33
+ jsxImportSource: "octane",
34
+ verbatimModuleSyntax: true,
35
+ isolatedModules: true,
36
+ resolveJsonModule: true,
37
+ skipLibCheck: true,
38
+ types: ["vite/client", "tanejs/virtual-routes"],
39
+ },
40
+ // `.tane/types.d.ts` is written by the dev server and by `tane build`; it
41
+ // is what makes <Link href> check against the real route list.
42
+ include: ["app", "tane.config.ts", ".tane/types.d.ts"],
43
+ }, null, 2)}\n`;
44
+ // Routes are .tsrx — Octane's own syntax. A component body is `@{ … }` and
45
+ // renders a single node, so several elements need a <>…</> around them.
46
+ const LAYOUT = `import { Link, type Metadata } from "tanejs";
47
+ import type { OctaneNode } from "octane";
48
+
49
+ export const metadata: Metadata = {
50
+ title: "APP_NAME",
51
+ description: "Built with tane.",
52
+ };
53
+
54
+ export default function RootLayout(props: { children: OctaneNode }) @{
55
+ <div class="mx-auto max-w-2xl space-y-6 p-8 text-slate-900">
56
+ <nav class="flex gap-4 border-b border-slate-200 pb-4 text-sm">
57
+ <Link href="/" class="text-slate-600 hover:text-slate-900 hover:underline">
58
+ Home
59
+ </Link>
60
+ <Link href="/about" class="text-slate-600 hover:text-slate-900 hover:underline">
61
+ About
62
+ </Link>
63
+ </nav>
64
+ <main class="space-y-4">{props.children}</main>
65
+ </div>
66
+ }
67
+ `;
68
+ const PAGE = `export default function HomePage() @{
69
+ <>
70
+ <h1 class="text-3xl font-semibold tracking-tight">APP_NAME</h1>
71
+ <p class="text-slate-600">Edit app/page.tsrx and save — the change is live.</p>
72
+ </>
73
+ }
74
+ `;
75
+ const ABOUT_PAGE = `import type { Metadata } from "tanejs";
76
+
77
+ export const metadata: Metadata = { title: "About — APP_NAME" };
78
+
79
+ export default function AboutPage() @{
80
+ <h1 class="text-2xl font-semibold tracking-tight">About</h1>
81
+ }
82
+ `;
83
+ const NOT_FOUND = `export default function NotFound() @{
84
+ <h1 class="text-2xl font-semibold tracking-tight">Page not found</h1>
85
+ }
86
+ `;
87
+ const CONFIG = `import { defineConfig } from "tanejs/vite";
88
+ import tailwindcss from "@tailwindcss/vite";
89
+
90
+ // appDir, basePath, alias, outDir and server all have defaults — the \`vite\`
91
+ // field is the escape hatch for anything Vite-specific.
92
+ export default defineConfig({
93
+ vite: { plugins: [tailwindcss()] },
94
+ });
95
+ `;
96
+ // Picked up automatically as `virtual:tane-global-css`; no import needed.
97
+ const GLOBAL_CSS = `@import "tailwindcss";
98
+ `;
99
+ const GITIGNORE = `node_modules
100
+ dist
101
+ .tane
102
+ *.tsbuildinfo
103
+ `;
104
+ function readme(name) {
105
+ return `# ${name}
106
+
107
+ \`\`\`bash
108
+ npm install
109
+ npm run dev
110
+ \`\`\`
111
+
112
+ - \`app/\` — routes. \`page\` makes a route public, \`layout\` wraps its children,
113
+ and \`loading\`, \`error\` and \`not-found\` are the segment's boundaries.
114
+ - \`app/global.css\` — Tailwind's entry, picked up automatically.
115
+ - \`tane.config.ts\` — optional. \`appDir\`, \`basePath\`, \`alias\`, \`outDir\`,
116
+ \`server\` and a \`vite\` field for anything Vite-specific.
117
+
118
+ \`npm run build\` writes \`dist/client\` and \`dist/server\`; \`npm start\` serves them.
119
+
120
+ ## .tsrx
121
+
122
+ Routes are written in Octane's \`.tsrx\`: a component body is \`@{ … }\` rather
123
+ than \`return (…)\`, and it renders a single node — wrap siblings in \`<>…</>\`.
124
+ Control flow is \`@for\`, \`@if\` and friends. Plain \`.tsx\` works too; the router
125
+ takes \`.tsrx\`, \`.tsx\`, \`.jsx\`, \`.ts\` and \`.js\`.
126
+
127
+ \`tsc\` does not know the \`.tsrx\` extension and skips those files, so a bare
128
+ \`tsc --noEmit\` will pass without having checked your routes. Use Octane's Volar
129
+ integration (\`octane/compiler/volar\`) for editor diagnostics and type-checked
130
+ \`<Link href>\`.
131
+ `;
132
+ }
133
+ /**
134
+ * The files a new app is made of, as a path → contents map. Kept separate from
135
+ * disk writing so the shape of a scaffolded project can be asserted directly.
136
+ */
137
+ export function templateFiles(options) {
138
+ const fill = (source) => source.replaceAll("APP_NAME", options.name);
139
+ return {
140
+ "package.json": packageJson(options),
141
+ "tsconfig.json": TSCONFIG,
142
+ "tane.config.ts": CONFIG,
143
+ ".gitignore": GITIGNORE,
144
+ "README.md": readme(options.name),
145
+ "app/global.css": GLOBAL_CSS,
146
+ "app/layout.tsrx": fill(LAYOUT),
147
+ "app/page.tsrx": fill(PAGE),
148
+ "app/about/page.tsrx": fill(ABOUT_PAGE),
149
+ "app/not-found.tsrx": NOT_FOUND,
150
+ };
151
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAQA,MAAM,YAAY,GAAG,QAAQ,CAAC;AAC9B,MAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,SAAS,WAAW,CAAC,OAAwB;IAC3C,OAAO,GAAG,IAAI,CAAC,SAAS,CACtB;QACE,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,YAAY;SACpB;QACD,YAAY,EAAE;YACZ,MAAM,EAA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,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,OAAO;QACL,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC;QACpC,eAAe,EAAE,QAAQ;QACzB,gBAAgB,EAAE,MAAM;QACxB,YAAY,EAAE,SAAS;QACvB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QACjC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC;QAC9B,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;QAC1B,oBAAoB,EAAE,IAAI,CAAC,UAAU,CAAC;QACtC,mBAAmB,EAAE,SAAS;KAC/B,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "create-tanejs",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Scaffold a tane app: npm create tane my-app",
7
+ "author": "Eray",
8
+ "homepage": "https://github.com/tanejs/tane/tree/main/packages/create-app#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/tanejs/tane.git",
12
+ "directory": "packages/create-app"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/tanejs/tane/issues"
16
+ },
17
+ "keywords": [
18
+ "tane",
19
+ "octane",
20
+ "octanejs",
21
+ "scaffold",
22
+ "create",
23
+ "starter"
24
+ ],
25
+ "engines": {
26
+ "node": ">=22"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "bin"
31
+ ],
32
+ "main": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "bin": {
35
+ "create-tanejs": "./bin/create-tanejs.js"
36
+ },
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ }
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.build.json",
45
+ "typecheck": "tsc -p tsconfig.json"
46
+ }
47
+ }