create-tsrouter-app 0.5.0-alpha → 0.5.0-alpha.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/.github/ISSUE_TEMPLATE/config.yml +1 -1
- package/.github/workflows/ci.yml +2 -0
- package/README.md +9 -1
- package/dist/add.js +127 -0
- package/dist/cli.js +23 -4
- package/dist/config-file.js +22 -0
- package/dist/constants.js +1 -0
- package/dist/create-app.js +165 -88
- package/dist/environment.js +113 -0
- package/dist/mcp.js +46 -4
- package/dist/options.js +43 -21
- package/dist/package-manager.js +1 -1
- package/dist/toolchain.js +2 -0
- package/dist/utils.js +8 -0
- package/package.json +5 -1
- package/src/add.ts +184 -0
- package/src/cli.ts +34 -3
- package/src/config-file.ts +44 -0
- package/src/constants.ts +2 -0
- package/src/create-app.ts +250 -104
- package/src/environment.ts +151 -0
- package/src/mcp.ts +51 -4
- package/src/options.ts +43 -23
- package/src/package-manager.ts +1 -1
- package/src/toolchain.ts +3 -0
- package/src/types.ts +4 -0
- package/src/utils.ts +10 -0
- package/templates/react/add-on/form/assets/src/components/demo.FormComponents.tsx.ejs +300 -0
- package/templates/react/add-on/form/assets/src/hooks/demo.form-context.ts +4 -0
- package/templates/react/add-on/form/assets/src/hooks/demo.form.ts +22 -0
- package/templates/react/add-on/form/assets/src/routes/demo.form.address.tsx.ejs +213 -0
- package/templates/react/add-on/form/assets/src/routes/demo.form.simple.tsx.ejs +77 -0
- package/templates/react/add-on/form/info.json +16 -3
- package/templates/react/add-on/form/package.json +2 -1
- package/templates/react/add-on/sentry/assets/src/app/global-middleware.ts +1 -1
- package/templates/react/add-on/sentry/assets/src/routes/demo.sentry.testing.tsx +1 -1
- package/templates/react/add-on/shadcn/assets/components.json +21 -0
- package/templates/react/add-on/shadcn/assets/src/lib/utils.ts +6 -0
- package/templates/react/add-on/shadcn/assets/src/styles.css +138 -0
- package/templates/react/add-on/shadcn/info.json +1 -5
- package/templates/react/add-on/shadcn/package.json +9 -0
- package/templates/react/add-on/start/assets/_dot_gitignore.append +2 -0
- package/templates/react/add-on/start/assets/{app.config.ts → app.config.ts.ejs} +5 -2
- package/templates/react/add-on/start/assets/src/api.ts +1 -1
- package/templates/react/add-on/start/assets/src/client.tsx +1 -1
- package/templates/react/add-on/start/assets/src/router.tsx.ejs +20 -6
- package/templates/react/add-on/start/assets/src/routes/api.demo-names.ts +1 -1
- package/templates/react/add-on/start/assets/src/routes/demo.start.api-request.tsx.ejs +30 -30
- package/templates/react/add-on/start/assets/src/routes/demo.start.server-funcs.tsx +3 -2
- package/templates/react/add-on/start/assets/src/ssr.tsx +2 -2
- package/templates/react/add-on/start/info.json +1 -2
- package/templates/react/add-on/start/package.json +2 -1
- package/templates/react/add-on/table/assets/src/data/demo-table-data.ts +50 -0
- package/templates/react/add-on/table/assets/src/routes/demo.table.tsx.ejs +373 -0
- package/templates/react/add-on/table/info.json +13 -0
- package/templates/react/add-on/table/package.json +7 -0
- package/templates/react/add-on/tanstack-query/assets/src/integrations/tanstack-query/{provider.tsx → root-provider.tsx} +7 -1
- package/templates/react/base/README.md.ejs +30 -14
- package/templates/react/base/_dot_vscode/settings.biome.json +38 -0
- package/templates/react/base/package.biome.json +10 -0
- package/templates/react/base/package.json +2 -2
- package/templates/react/base/src/components/Header.tsx.ejs +3 -1
- package/templates/react/base/toolchain/biome.json +31 -0
- package/templates/react/base/vite.config.js.ejs +2 -2
- package/templates/react/code-router/src/main.tsx.ejs +19 -5
- package/templates/react/example/tanchat/assets/public/example-guitar-dune.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-motherboard.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-racing.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-steamer-trunk.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-steampunk.jpg +0 -0
- package/templates/react/example/tanchat/assets/public/example-guitar-underwater.jpg +0 -0
- package/templates/react/example/tanchat/assets/src/components/example-AIAssistant.tsx +173 -0
- package/templates/react/example/tanchat/assets/src/components/example-GuitarRecommendation.tsx +47 -0
- package/templates/react/example/tanchat/assets/src/data/example-guitars.ts +73 -0
- package/templates/react/example/tanchat/assets/src/integrations/tanchat/header-user.tsx +5 -0
- package/templates/react/example/tanchat/assets/src/routes/example.chat.tsx +159 -0
- package/templates/react/example/tanchat/assets/src/routes/example.guitars/$guitarId.tsx +50 -0
- package/templates/react/example/tanchat/assets/src/routes/example.guitars/index.tsx +54 -0
- package/templates/react/example/tanchat/assets/src/store/example-assistant.ts +3 -0
- package/templates/react/example/tanchat/assets/src/utils/demo.ai.ts +52 -104
- package/templates/react/example/tanchat/assets/src/utils/demo.tools.ts +43 -0
- package/templates/react/example/tanchat/info.json +5 -1
- package/templates/react/example/tanchat/package.json +5 -1
- package/templates/react/file-router/package.fr.json +1 -1
- package/templates/react/file-router/src/main.tsx.ejs +24 -4
- package/templates/react/file-router/src/routes/__root.tsx.ejs +12 -9
- package/templates/solid/add-on/form/assets/src/routes/demo.form.tsx.ejs +310 -106
- package/templates/solid/add-on/form/info.json +1 -1
- package/templates/solid/add-on/form/package.json +1 -1
- package/templates/solid/base/README.md.ejs +5 -5
- package/templates/solid/base/_dot_vscode/settings.biome.json +38 -0
- package/templates/solid/base/package.biome.json +10 -0
- package/templates/solid/base/package.json +1 -1
- package/templates/solid/base/toolchain/biome.json +31 -0
- package/templates/solid/base/vite.config.js.ejs +1 -1
- package/templates/solid/code-router/src/main.tsx.ejs +7 -5
- package/templates/solid/example/tanchat/README.md +52 -0
- package/templates/solid/example/tanchat/assets/ai-streaming-server/README.md +110 -0
- package/templates/solid/example/tanchat/assets/ai-streaming-server/_dot_env.example +1 -0
- package/templates/solid/example/tanchat/assets/ai-streaming-server/package.json +26 -0
- package/templates/solid/example/tanchat/assets/ai-streaming-server/src/index.ts +102 -0
- package/templates/solid/example/tanchat/assets/ai-streaming-server/tsconfig.json +15 -0
- package/templates/solid/example/tanchat/assets/src/components/demo.SettingsDialog.tsx +149 -0
- package/templates/solid/example/tanchat/assets/src/demo.index.css +227 -0
- package/templates/solid/example/tanchat/assets/src/lib/demo-store.ts +13 -0
- package/templates/solid/example/tanchat/assets/src/routes/example.chat.tsx +435 -0
- package/templates/{react → solid}/example/tanchat/assets/src/store/demo.hooks.ts +2 -6
- package/templates/solid/example/tanchat/info.json +14 -0
- package/templates/solid/example/tanchat/package.json +7 -0
- package/templates/solid/file-router/src/main.tsx.ejs +5 -2
- package/templates/solid/file-router/src/routes/__root.tsx.ejs +3 -3
- package/tests/cra.test.ts +232 -0
- package/tests/snapshots/cra/cr-js-npm.json +33 -0
- package/tests/snapshots/cra/cr-ts-npm.json +34 -0
- package/tests/snapshots/cra/fr-ts-npm.json +34 -0
- package/tests/snapshots/cra/fr-ts-tw-npm.json +33 -0
- package/tests/snapshots/cra/solid-cr-js-npm.json +31 -0
- package/tests/snapshots/cra/solid-cr-ts-npm.json +32 -0
- package/tests/snapshots/cra/solid-fr-ts-npm.json +33 -0
- package/tests/snapshots/cra/solid-fr-ts-tw-npm.json +32 -0
- package/tests/test-utilities.ts +83 -0
- package/templates/react/add-on/form/assets/src/routes/demo.form.tsx.ejs +0 -62
- package/templates/react/example/tanchat/assets/src/components/demo.SettingsDialog.tsx +0 -148
- package/templates/react/example/tanchat/assets/src/routes/example.chat.tsx.ejs +0 -375
- /package/templates/{react → solid}/example/tanchat/assets/src/store/demo.store.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
blank_issues_enabled: false
|
|
2
2
|
contact_links:
|
|
3
3
|
- name: 🤔 Feature Requests & Questions
|
|
4
|
-
url: https://github.com/tanstack/
|
|
4
|
+
url: https://github.com/tanstack/create-tsrouter-app/discussions
|
|
5
5
|
about: Please ask and answer questions here.
|
|
6
6
|
- name: 💬 Community Chat
|
|
7
7
|
url: https://discord.gg/mQd7egN
|
package/.github/workflows/ci.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Create React App for TanStack Router
|
|
2
2
|
|
|
3
|
-
This CLI
|
|
3
|
+
This CLI application builds Tanstack Router applications that are the functional equivalent of [Create React App](https://create-react-app.dev/).
|
|
4
4
|
|
|
5
5
|
To help accelerate the migration away from `create-react-app` we created the `create-tsrouter-app` CLI which is a plug-n-play replacement for CRA.
|
|
6
6
|
|
|
@@ -30,6 +30,7 @@ This will start an interactive CLI that guides you through the setup process, al
|
|
|
30
30
|
- TypeScript support
|
|
31
31
|
- Tailwind CSS integration
|
|
32
32
|
- Package manager
|
|
33
|
+
- Toolchain
|
|
33
34
|
- Git initialization
|
|
34
35
|
|
|
35
36
|
## Command Line Options
|
|
@@ -45,6 +46,7 @@ Available options:
|
|
|
45
46
|
- `--template <type>`: Choose between `file-router`, `typescript`, or `javascript`
|
|
46
47
|
- `--tailwind`: Enable Tailwind CSS
|
|
47
48
|
- `--package-manager`: Specify your preferred package manager (`npm`, `yarn`, `pnpm`, `bun`, or `deno`)
|
|
49
|
+
- `--toolchain`: Specify your toolchain solution for formatting/linting (`biome`)
|
|
48
50
|
- `--no-git`: Do not initialize a git repository
|
|
49
51
|
- `--add-ons`: Enable add-on selection or specify add-ons to install
|
|
50
52
|
|
|
@@ -94,6 +96,12 @@ Choose your preferred package manager (`npm`, `bun`, `yarn`, `pnpm`, or `deno`)
|
|
|
94
96
|
|
|
95
97
|
Extensive documentation on using the TanStack Router, migrating to a File Base Routing approach, as well as integrating [@tanstack/react-query](https://tanstack.com/query/latest) and [@tanstack/store](https://tanstack.com/store/latest) can be found in the generated `README.md` for your project.
|
|
96
98
|
|
|
99
|
+
### Toolchain
|
|
100
|
+
|
|
101
|
+
Choose your preferred solution for formatting and linting either through the interactive CLI or using the `--toolchain` flag.
|
|
102
|
+
|
|
103
|
+
Setting this flag to `biome` will configure it as your toolchain of choice, adding a `biome.json` to the root of the project. Consult the [biome documentation](https://biomejs.dev/guides/getting-started/) for further customization.
|
|
104
|
+
|
|
97
105
|
## Add-ons (experimental)
|
|
98
106
|
|
|
99
107
|
You can enable add-on selection:
|
package/dist/add.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { existsSync, statSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, resolve } from 'node:path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { execa, execaSync } from 'execa';
|
|
6
|
+
import { cancel, confirm, intro, isCancel, log, outro, spinner, } from '@clack/prompts';
|
|
7
|
+
import { CONFIG_FILE } from './constants.js';
|
|
8
|
+
import { createDefaultEnvironment, createMemoryEnvironment, } from './environment.js';
|
|
9
|
+
import { createApp } from './create-app.js';
|
|
10
|
+
import { finalizeAddOns } from './add-ons.js';
|
|
11
|
+
import { sortObject } from './utils.js';
|
|
12
|
+
import { readConfigFile, writeConfigFile } from './config-file.js';
|
|
13
|
+
function isDirectory(path) {
|
|
14
|
+
return statSync(path).isDirectory();
|
|
15
|
+
}
|
|
16
|
+
async function hasPendingGitChanges() {
|
|
17
|
+
const status = await execaSync('git', ['status', '--porcelain']);
|
|
18
|
+
return status.stdout.length > 0;
|
|
19
|
+
}
|
|
20
|
+
async function createOptions(json, addOns) {
|
|
21
|
+
return {
|
|
22
|
+
...json,
|
|
23
|
+
tailwind: true,
|
|
24
|
+
chosenAddOns: await finalizeAddOns(json.framework, json.mode, [
|
|
25
|
+
...json.existingAddOns,
|
|
26
|
+
...addOns,
|
|
27
|
+
]),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function runCreateApp(options) {
|
|
31
|
+
const { environment, output } = createMemoryEnvironment();
|
|
32
|
+
await createApp(options, {
|
|
33
|
+
silent: true,
|
|
34
|
+
environment,
|
|
35
|
+
cwd: process.cwd(),
|
|
36
|
+
});
|
|
37
|
+
return output;
|
|
38
|
+
}
|
|
39
|
+
export async function add(addOns, { silent = false, } = {}) {
|
|
40
|
+
const persistedOptions = await readConfigFile(process.cwd());
|
|
41
|
+
if (!persistedOptions) {
|
|
42
|
+
console.error(`${chalk.red('There is no .cta.json file in your project.')}
|
|
43
|
+
|
|
44
|
+
This is probably because this was created with an older version of create-tsrouter-app.`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!silent) {
|
|
48
|
+
intro(`Adding ${addOns.join(', ')} to the project...`);
|
|
49
|
+
}
|
|
50
|
+
if (await hasPendingGitChanges()) {
|
|
51
|
+
log.error(`${chalk.red('You have pending git changes.')} Please commit or stash them before adding add-ons.`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const newOptions = await createOptions(persistedOptions, addOns);
|
|
55
|
+
const output = await runCreateApp(newOptions);
|
|
56
|
+
const overwrittenFiles = [];
|
|
57
|
+
const changedFiles = [];
|
|
58
|
+
const contentMap = new Map();
|
|
59
|
+
for (const file of Object.keys(output.files)) {
|
|
60
|
+
const relativeFile = file.replace(process.cwd(), '');
|
|
61
|
+
if (existsSync(file)) {
|
|
62
|
+
if (!isDirectory(file)) {
|
|
63
|
+
const contents = (await readFile(file)).toString();
|
|
64
|
+
if (['package.json', CONFIG_FILE].includes(basename(file)) ||
|
|
65
|
+
contents !== output.files[file]) {
|
|
66
|
+
overwrittenFiles.push(relativeFile);
|
|
67
|
+
contentMap.set(relativeFile, output.files[file]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
changedFiles.push(relativeFile);
|
|
73
|
+
contentMap.set(relativeFile, output.files[file]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (overwrittenFiles.length > 0 && !silent) {
|
|
77
|
+
log.warn(`${chalk.yellow('The following will be overwritten:')}\n${overwrittenFiles.join('\n')}`);
|
|
78
|
+
const shouldContinue = await confirm({
|
|
79
|
+
message: 'Do you want to continue?',
|
|
80
|
+
});
|
|
81
|
+
if (isCancel(shouldContinue)) {
|
|
82
|
+
cancel('Operation cancelled.');
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const file of [...changedFiles, ...overwrittenFiles]) {
|
|
87
|
+
const targetFile = `.${file}`;
|
|
88
|
+
const fName = basename(file);
|
|
89
|
+
const contents = contentMap.get(file);
|
|
90
|
+
if (fName === 'package.json') {
|
|
91
|
+
const currentJson = JSON.parse((await readFile(resolve(fName), 'utf-8')).toString());
|
|
92
|
+
const newJson = JSON.parse(contents);
|
|
93
|
+
currentJson.scripts = newJson.scripts;
|
|
94
|
+
currentJson.dependencies = sortObject({
|
|
95
|
+
...currentJson.dependencies,
|
|
96
|
+
...newJson.dependencies,
|
|
97
|
+
});
|
|
98
|
+
currentJson.devDependencies = sortObject({
|
|
99
|
+
...currentJson.devDependencies,
|
|
100
|
+
...newJson.devDependencies,
|
|
101
|
+
});
|
|
102
|
+
await writeFile(targetFile, JSON.stringify(currentJson, null, 2));
|
|
103
|
+
}
|
|
104
|
+
else if (fName !== CONFIG_FILE) {
|
|
105
|
+
await mkdir(resolve(dirname(targetFile)), { recursive: true });
|
|
106
|
+
await writeFile(resolve(targetFile), contents);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Handle commands
|
|
110
|
+
const originalOutput = await runCreateApp(await createOptions(persistedOptions, []));
|
|
111
|
+
const originalCommands = new Set(originalOutput.commands.map((c) => [c.command, ...c.args].join(' ')));
|
|
112
|
+
for (const command of output.commands) {
|
|
113
|
+
const commandString = [command.command, ...command.args].join(' ');
|
|
114
|
+
if (!originalCommands.has(commandString)) {
|
|
115
|
+
await execa(command.command, command.args);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const realEnvironment = createDefaultEnvironment();
|
|
119
|
+
writeConfigFile(realEnvironment, process.cwd(), newOptions);
|
|
120
|
+
const s = silent ? null : spinner();
|
|
121
|
+
s?.start(`Installing dependencies via ${newOptions.packageManager}...`);
|
|
122
|
+
await realEnvironment.execute(newOptions.packageManager, ['install'], resolve(process.cwd()));
|
|
123
|
+
s?.stop(`Installed dependencies`);
|
|
124
|
+
if (!silent) {
|
|
125
|
+
outro('Add-ons added successfully!');
|
|
126
|
+
}
|
|
127
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -3,14 +3,24 @@ import { intro, log } from '@clack/prompts';
|
|
|
3
3
|
import { createApp } from './create-app.js';
|
|
4
4
|
import { normalizeOptions, promptForOptions } from './options.js';
|
|
5
5
|
import { SUPPORTED_PACKAGE_MANAGERS } from './package-manager.js';
|
|
6
|
+
import { SUPPORTED_TOOLCHAINS } from './toolchain.js';
|
|
6
7
|
import runServer from './mcp.js';
|
|
7
8
|
import { listAddOns } from './add-ons.js';
|
|
8
9
|
import { DEFAULT_FRAMEWORK, SUPPORTED_FRAMEWORKS } from './constants.js';
|
|
10
|
+
import { createDefaultEnvironment } from './environment.js';
|
|
11
|
+
import { add } from './add.js';
|
|
9
12
|
export function cli() {
|
|
10
13
|
const program = new Command();
|
|
11
14
|
program
|
|
12
15
|
.name('create-tsrouter-app')
|
|
13
|
-
.description('CLI to create a new TanStack application')
|
|
16
|
+
.description('CLI to create a new TanStack application');
|
|
17
|
+
program
|
|
18
|
+
.command('add')
|
|
19
|
+
.argument('add-on', 'Name of the add-on (or add-ons separated by commas)')
|
|
20
|
+
.action(async (addOn) => {
|
|
21
|
+
await add(addOn.split(',').map((addon) => addon.trim()));
|
|
22
|
+
});
|
|
23
|
+
program // 104 22
|
|
14
24
|
.argument('[project-name]', 'name of the project')
|
|
15
25
|
.option('--no-git', 'do not create a git repository')
|
|
16
26
|
.option('--framework <type>', 'project framework (solid, react)', (value) => {
|
|
@@ -32,6 +42,12 @@ export function cli() {
|
|
|
32
42
|
throw new InvalidArgumentError(`Invalid package manager: ${value}. The following are allowed: ${SUPPORTED_PACKAGE_MANAGERS.join(', ')}`);
|
|
33
43
|
}
|
|
34
44
|
return value;
|
|
45
|
+
})
|
|
46
|
+
.option(`--toolchain <${SUPPORTED_TOOLCHAINS.join('|')}>`, `Explicitly tell the CLI to use this toolchain`, (value) => {
|
|
47
|
+
if (!SUPPORTED_TOOLCHAINS.includes(value)) {
|
|
48
|
+
throw new InvalidArgumentError(`Invalid toolchain: ${value}. The following are allowed: ${SUPPORTED_TOOLCHAINS.join(', ')}`);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
35
51
|
})
|
|
36
52
|
.option('--tailwind', 'add Tailwind CSS', false)
|
|
37
53
|
.option('--add-ons [...add-ons]', 'pick from a list of available add-ons (comma separated list)', (value) => {
|
|
@@ -43,12 +59,13 @@ export function cli() {
|
|
|
43
59
|
})
|
|
44
60
|
.option('--list-add-ons', 'list all available add-ons', false)
|
|
45
61
|
.option('--mcp', 'run the MCP server', false)
|
|
62
|
+
.option('--mcp-sse', 'run the MCP server in SSE mode', false)
|
|
46
63
|
.action(async (projectName, options) => {
|
|
47
64
|
if (options.listAddOns) {
|
|
48
65
|
await listAddOns(options);
|
|
49
66
|
}
|
|
50
|
-
else if (options.mcp) {
|
|
51
|
-
await runServer();
|
|
67
|
+
else if (options.mcp || options.mcpSse) {
|
|
68
|
+
await runServer(!!options.mcpSse);
|
|
52
69
|
}
|
|
53
70
|
else {
|
|
54
71
|
try {
|
|
@@ -64,7 +81,9 @@ export function cli() {
|
|
|
64
81
|
intro("Let's configure your TanStack application");
|
|
65
82
|
finalOptions = await promptForOptions(cliOptions);
|
|
66
83
|
}
|
|
67
|
-
await createApp(finalOptions
|
|
84
|
+
await createApp(finalOptions, {
|
|
85
|
+
environment: createDefaultEnvironment(),
|
|
86
|
+
});
|
|
68
87
|
}
|
|
69
88
|
catch (error) {
|
|
70
89
|
log.error(error instanceof Error
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { CONFIG_FILE } from './constants.js';
|
|
4
|
+
export async function writeConfigFile(environment, targetDir, options) {
|
|
5
|
+
const persistedOptions = {
|
|
6
|
+
...options,
|
|
7
|
+
existingAddOns: options.chosenAddOns.map((addOn) => addOn.id),
|
|
8
|
+
};
|
|
9
|
+
delete persistedOptions.addOns;
|
|
10
|
+
delete persistedOptions.chosenAddOns;
|
|
11
|
+
await environment.writeFile(resolve(targetDir, CONFIG_FILE), JSON.stringify(persistedOptions, null, 2));
|
|
12
|
+
}
|
|
13
|
+
export async function readConfigFile(targetDir) {
|
|
14
|
+
try {
|
|
15
|
+
const configFile = resolve(targetDir, CONFIG_FILE);
|
|
16
|
+
const config = await readFile(configFile, 'utf8');
|
|
17
|
+
return JSON.parse(config);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/constants.js
CHANGED