@baseplate-dev/project-builder-cli 0.1.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.
@@ -0,0 +1,12 @@
1
+ import { getDefaultPlugins } from '@baseplate-dev/project-builder-common';
2
+ import { createNodeSchemaParserContext } from '@baseplate-dev/project-builder-server';
3
+ import { logger } from './logger.js';
4
+ /**
5
+ * Creates a schema parser context for the given directory.
6
+ * @param directory - The directory to create the schema parser context for.
7
+ * @returns A promise that resolves to the schema parser context.
8
+ */
9
+ export async function createSchemaParserContext(directory) {
10
+ const builtInPlugins = await getDefaultPlugins(logger);
11
+ return createNodeSchemaParserContext(directory, logger, builtInPlugins);
12
+ }
@@ -0,0 +1,13 @@
1
+ import type { BaseplateUserConfig } from '@baseplate-dev/project-builder-server';
2
+ /**
3
+ * Get the user config for the project builder.
4
+ *
5
+ * @returns The user config for the project builder.
6
+ */
7
+ export declare function getUserConfig(): Promise<BaseplateUserConfig>;
8
+ /**
9
+ * Write the user config for the project builder.
10
+ *
11
+ * @param config - The user config to write.
12
+ */
13
+ export declare function writeUserConfig(config: BaseplateUserConfig): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { userConfigSchema } from '@baseplate-dev/project-builder-server';
2
+ import { handleFileNotFoundError, readJsonWithSchema, writeStablePrettyJson, } from '@baseplate-dev/utils/node';
3
+ import { mkdir } from 'node:fs/promises';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ function getConfigPath() {
7
+ const homeDir = os.homedir();
8
+ return path.join(homeDir, '.baseplate', 'config.json');
9
+ }
10
+ /**
11
+ * Get the user config for the project builder.
12
+ *
13
+ * @returns The user config for the project builder.
14
+ */
15
+ export async function getUserConfig() {
16
+ const configPath = getConfigPath();
17
+ const config = await readJsonWithSchema(configPath, userConfigSchema).catch(handleFileNotFoundError);
18
+ return config ?? {};
19
+ }
20
+ /**
21
+ * Write the user config for the project builder.
22
+ *
23
+ * @param config - The user config to write.
24
+ */
25
+ export async function writeUserConfig(config) {
26
+ const configPath = getConfigPath();
27
+ const configDir = path.dirname(configPath);
28
+ await mkdir(configDir, { recursive: true });
29
+ await writeStablePrettyJson(configPath, config);
30
+ }