@baseplate-dev/create-project 0.4.2 → 0.4.4
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/dist/project-creator.js +23 -55
- package/dist/project-generator.d.ts +35 -0
- package/dist/project-generator.js +73 -0
- package/package.json +7 -5
- package/dist/exec.d.ts +0 -1
- package/dist/exec.js +0 -16
- package/templates/.gitignore +0 -141
- package/templates/.pnpmfile.cjs +0 -2
- package/templates/.template.npmrc +0 -14
- package/templates/README.md +0 -35
package/dist/project-creator.js
CHANGED
|
@@ -1,68 +1,36 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import fs from 'node:fs/promises';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import ora from 'ora';
|
|
5
|
-
import {
|
|
4
|
+
import { generateRootPackage } from './project-generator.js';
|
|
5
|
+
/**
|
|
6
|
+
* Shows a success message with instructions for getting started.
|
|
7
|
+
*/
|
|
8
|
+
function showSuccessMessage(directory) {
|
|
9
|
+
const relativePath = path.relative(process.cwd(), directory);
|
|
10
|
+
console.info('');
|
|
11
|
+
console.info(`
|
|
12
|
+
🎉 Congratulations! Your Baseplate project has been created. To get started, run the following command${relativePath === '' ? '' : 's'}:
|
|
13
|
+
${relativePath === '' ? '' : chalk.bold(`\ncd ${relativePath}`)}
|
|
14
|
+
${chalk.bold('pnpm baseplate serve')}
|
|
15
|
+
|
|
16
|
+
For more information, read the included README.md file.
|
|
17
|
+
`.trim());
|
|
18
|
+
}
|
|
6
19
|
export async function generateBaseplateProject({ packageName, directory, cliVersion, }) {
|
|
7
20
|
const spinner = ora({
|
|
8
21
|
text: 'Creating project files...',
|
|
9
22
|
}).start();
|
|
10
23
|
try {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const destinationPath = path.join(directory, destination);
|
|
16
|
-
await fs.mkdir(path.dirname(destinationPath), {
|
|
17
|
-
recursive: true,
|
|
18
|
-
});
|
|
19
|
-
await fs.writeFile(destinationPath, content);
|
|
20
|
-
};
|
|
21
|
-
const copyFile = async (templateSrc, destination) => {
|
|
22
|
-
// template files are stored at ../templates
|
|
23
|
-
const source = new URL(`../templates/${templateSrc}`, import.meta.url);
|
|
24
|
-
const sourceFile = await fs.readFile(source);
|
|
25
|
-
await writeFile(destination, sourceFile);
|
|
26
|
-
};
|
|
27
|
-
// write package.json
|
|
28
|
-
await writeFile('package.json', JSON.stringify({
|
|
24
|
+
// Generate root package files using sync engine
|
|
25
|
+
// This includes package.json, turbo.json, pnpm-workspace.yaml, .gitignore, etc.
|
|
26
|
+
// It also runs pnpm install as a post-write command
|
|
27
|
+
await generateRootPackage({
|
|
29
28
|
name: packageName,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
license: 'UNLICENSED',
|
|
34
|
-
author: '<AUTHOR>',
|
|
35
|
-
scripts: {
|
|
36
|
-
'baseplate:serve': 'baseplate serve',
|
|
37
|
-
'baseplate:generate': 'baseplate generate',
|
|
38
|
-
preinstall: 'npx only-allow pnpm',
|
|
39
|
-
},
|
|
40
|
-
devDependencies: {
|
|
41
|
-
'@baseplate-dev/project-builder-cli': cliVersion,
|
|
42
|
-
},
|
|
43
|
-
packageManager: 'pnpm@10.18.3',
|
|
44
|
-
engines: {
|
|
45
|
-
node: '^22.0.0',
|
|
46
|
-
pnpm: '^10.18.3',
|
|
47
|
-
},
|
|
48
|
-
volta: {
|
|
49
|
-
node: '22.18.0',
|
|
50
|
-
},
|
|
51
|
-
}, null, 2));
|
|
52
|
-
await copyFile('.gitignore', '.gitignore');
|
|
53
|
-
await copyFile('.template.npmrc', '.npmrc');
|
|
54
|
-
await copyFile('README.md', 'README.md');
|
|
29
|
+
cliVersion,
|
|
30
|
+
directory,
|
|
31
|
+
});
|
|
55
32
|
spinner.succeed();
|
|
56
|
-
|
|
57
|
-
const relativePath = path.relative(process.cwd(), directory);
|
|
58
|
-
console.info('');
|
|
59
|
-
console.info(`
|
|
60
|
-
🎉 Congratulations! Your Baseplate project has been created. To get started, run the following command${relativePath === '' ? '' : 's'}:
|
|
61
|
-
${relativePath === '' ? '' : chalk.bold(`\ncd ${relativePath}`)}
|
|
62
|
-
${chalk.bold('pnpm baseplate serve')}
|
|
63
|
-
|
|
64
|
-
For more information, read the included README.md file.
|
|
65
|
-
`.trim());
|
|
33
|
+
showSuccessMessage(directory);
|
|
66
34
|
}
|
|
67
35
|
finally {
|
|
68
36
|
if (spinner.isSpinning) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ProjectDefinition } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for generating an initial project.
|
|
4
|
+
*/
|
|
5
|
+
interface InitialProjectConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the project (used in package.json and project definition).
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* The CLI version to use for the project.
|
|
12
|
+
*/
|
|
13
|
+
cliVersion: string;
|
|
14
|
+
/**
|
|
15
|
+
* The absolute path to the project directory.
|
|
16
|
+
*/
|
|
17
|
+
directory: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a placeholder project definition with isInitialized: false.
|
|
21
|
+
* This definition can be used to bootstrap a new Baseplate project.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Configuration for the initial project
|
|
24
|
+
* @returns A ProjectDefinition with isInitialized: false
|
|
25
|
+
*/
|
|
26
|
+
export declare function createInitialProjectDefinition(config: InitialProjectConfig): ProjectDefinition;
|
|
27
|
+
/**
|
|
28
|
+
* Generates the root package files using the Baseplate sync engine.
|
|
29
|
+
* This creates all standard root-level files (package.json, turbo.json, etc.)
|
|
30
|
+
* and writes the project definition to baseplate/project-definition.json.
|
|
31
|
+
*
|
|
32
|
+
* @param config - Configuration for the initial project
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateRootPackage(config: InitialProjectConfig): Promise<void>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getLatestMigrationVersion } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { generateProjectId, SyncMetadataController, syncProject, } from '@baseplate-dev/project-builder-server';
|
|
3
|
+
import { createConsoleLogger } from '@baseplate-dev/sync';
|
|
4
|
+
import { stringifyPrettyStable } from '@baseplate-dev/utils';
|
|
5
|
+
import fs from 'node:fs/promises';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a placeholder project definition with isInitialized: false.
|
|
9
|
+
* This definition can be used to bootstrap a new Baseplate project.
|
|
10
|
+
*
|
|
11
|
+
* @param config - Configuration for the initial project
|
|
12
|
+
* @returns A ProjectDefinition with isInitialized: false
|
|
13
|
+
*/
|
|
14
|
+
export function createInitialProjectDefinition(config) {
|
|
15
|
+
return {
|
|
16
|
+
settings: {
|
|
17
|
+
general: {
|
|
18
|
+
name: config.name,
|
|
19
|
+
packageScope: '',
|
|
20
|
+
portOffset: 3000,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
features: [],
|
|
24
|
+
cliVersion: config.cliVersion,
|
|
25
|
+
apps: [],
|
|
26
|
+
models: [],
|
|
27
|
+
isInitialized: false,
|
|
28
|
+
schemaVersion: getLatestMigrationVersion(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generates the root package files using the Baseplate sync engine.
|
|
33
|
+
* This creates all standard root-level files (package.json, turbo.json, etc.)
|
|
34
|
+
* and writes the project definition to baseplate/project-definition.json.
|
|
35
|
+
*
|
|
36
|
+
* @param config - Configuration for the initial project
|
|
37
|
+
*/
|
|
38
|
+
export async function generateRootPackage(config) {
|
|
39
|
+
const definition = createInitialProjectDefinition(config);
|
|
40
|
+
const logger = createConsoleLogger('error');
|
|
41
|
+
// Create project directory and write project definition first
|
|
42
|
+
// This is needed because syncProject expects the definition to exist on disk
|
|
43
|
+
const baseplateDir = path.join(config.directory, 'baseplate');
|
|
44
|
+
await fs.mkdir(baseplateDir, { recursive: true });
|
|
45
|
+
await fs.writeFile(path.join(baseplateDir, 'project-definition.json'), stringifyPrettyStable(definition));
|
|
46
|
+
// Create minimal plugin store (no plugins for initial project)
|
|
47
|
+
const pluginStore = { availablePlugins: [] };
|
|
48
|
+
// Create parser context
|
|
49
|
+
const context = {
|
|
50
|
+
pluginStore,
|
|
51
|
+
cliVersion: config.cliVersion,
|
|
52
|
+
project: {
|
|
53
|
+
id: generateProjectId(config.directory),
|
|
54
|
+
name: config.name,
|
|
55
|
+
directory: config.directory,
|
|
56
|
+
isInternalExample: false,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
// Create sync metadata controller to set up .baseplate directory
|
|
60
|
+
const syncMetadataController = new SyncMetadataController(config.directory, logger);
|
|
61
|
+
// Use syncProject to generate all files and set up metadata
|
|
62
|
+
const result = await syncProject({
|
|
63
|
+
directory: config.directory,
|
|
64
|
+
logger,
|
|
65
|
+
context,
|
|
66
|
+
userConfig: {},
|
|
67
|
+
syncMetadataController,
|
|
68
|
+
overwrite: true,
|
|
69
|
+
});
|
|
70
|
+
if (result.status === 'error') {
|
|
71
|
+
throw new Error('Failed to generate project files');
|
|
72
|
+
}
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baseplate-dev/create-project",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "CLI starter kit for creating a new Baseplate project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -37,10 +37,12 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"chalk": "5.3.0",
|
|
39
39
|
"commander": "^12.1.0",
|
|
40
|
-
"execa": "9.3.0",
|
|
41
40
|
"ora": "^8.0.1",
|
|
42
|
-
"@baseplate-dev/project-builder-cli": "0.4.
|
|
43
|
-
"@baseplate-dev/
|
|
41
|
+
"@baseplate-dev/project-builder-cli": "0.4.4",
|
|
42
|
+
"@baseplate-dev/project-builder-lib": "0.4.4",
|
|
43
|
+
"@baseplate-dev/project-builder-server": "0.4.4",
|
|
44
|
+
"@baseplate-dev/sync": "0.4.4",
|
|
45
|
+
"@baseplate-dev/utils": "0.4.4"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"@types/node": "^22.17.2",
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
"tsx": "4.20.6",
|
|
51
53
|
"typescript": "5.8.3",
|
|
52
54
|
"vitest": "3.2.4",
|
|
53
|
-
"@baseplate-dev/tools": "0.4.
|
|
55
|
+
"@baseplate-dev/tools": "0.4.4"
|
|
54
56
|
},
|
|
55
57
|
"engines": {
|
|
56
58
|
"node": "^22.0.0"
|
package/dist/exec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function exec(command: string, cwd?: string): Promise<void>;
|
package/dist/exec.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
import ora from 'ora';
|
|
3
|
-
export async function exec(command, cwd) {
|
|
4
|
-
const spinner = ora({
|
|
5
|
-
text: `Running ${command}...`,
|
|
6
|
-
}).start();
|
|
7
|
-
try {
|
|
8
|
-
const [cmd, ...args] = command.split(' ');
|
|
9
|
-
await execa(cmd, args, { cwd });
|
|
10
|
-
spinner.succeed();
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
spinner.fail();
|
|
14
|
-
throw error;
|
|
15
|
-
}
|
|
16
|
-
}
|
package/templates/.gitignore
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# Logs
|
|
2
|
-
logs
|
|
3
|
-
*.log
|
|
4
|
-
npm-debug.log*
|
|
5
|
-
yarn-debug.log*
|
|
6
|
-
yarn-error.log*
|
|
7
|
-
lerna-debug.log*
|
|
8
|
-
.pnpm-debug.log*
|
|
9
|
-
|
|
10
|
-
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
-
|
|
13
|
-
# Runtime data
|
|
14
|
-
pids
|
|
15
|
-
*.pid
|
|
16
|
-
*.seed
|
|
17
|
-
*.pid.lock
|
|
18
|
-
|
|
19
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
20
|
-
lib-cov
|
|
21
|
-
|
|
22
|
-
# Coverage directory used by tools like istanbul
|
|
23
|
-
coverage
|
|
24
|
-
*.lcov
|
|
25
|
-
|
|
26
|
-
# nyc test coverage
|
|
27
|
-
.nyc_output
|
|
28
|
-
|
|
29
|
-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
30
|
-
.grunt
|
|
31
|
-
|
|
32
|
-
# Bower dependency directory (https://bower.io/)
|
|
33
|
-
bower_components
|
|
34
|
-
|
|
35
|
-
# node-waf configuration
|
|
36
|
-
.lock-wscript
|
|
37
|
-
|
|
38
|
-
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
39
|
-
build/Release
|
|
40
|
-
|
|
41
|
-
# Dependency directories
|
|
42
|
-
node_modules/
|
|
43
|
-
jspm_packages/
|
|
44
|
-
|
|
45
|
-
# Snowpack dependency directory (https://snowpack.dev/)
|
|
46
|
-
web_modules/
|
|
47
|
-
|
|
48
|
-
# TypeScript cache
|
|
49
|
-
*.tsbuildinfo
|
|
50
|
-
|
|
51
|
-
# Optional npm cache directory
|
|
52
|
-
.npm
|
|
53
|
-
|
|
54
|
-
# Optional eslint cache
|
|
55
|
-
.eslintcache
|
|
56
|
-
|
|
57
|
-
# Optional stylelint cache
|
|
58
|
-
.stylelintcache
|
|
59
|
-
|
|
60
|
-
# Microbundle cache
|
|
61
|
-
.rpt2_cache/
|
|
62
|
-
.rts2_cache_cjs/
|
|
63
|
-
.rts2_cache_es/
|
|
64
|
-
.rts2_cache_umd/
|
|
65
|
-
|
|
66
|
-
# Optional REPL history
|
|
67
|
-
.node_repl_history
|
|
68
|
-
|
|
69
|
-
# Output of 'npm pack'
|
|
70
|
-
*.tgz
|
|
71
|
-
|
|
72
|
-
# Yarn Integrity file
|
|
73
|
-
.yarn-integrity
|
|
74
|
-
|
|
75
|
-
# environment variable files
|
|
76
|
-
.env
|
|
77
|
-
.env.development.local
|
|
78
|
-
.env.test.local
|
|
79
|
-
.env.production.local
|
|
80
|
-
.env.local
|
|
81
|
-
|
|
82
|
-
# parcel-bundler cache (https://parceljs.org/)
|
|
83
|
-
.cache
|
|
84
|
-
.parcel-cache
|
|
85
|
-
|
|
86
|
-
# Next.js build output
|
|
87
|
-
.next
|
|
88
|
-
out
|
|
89
|
-
|
|
90
|
-
# Nuxt.js build / generate output
|
|
91
|
-
.nuxt
|
|
92
|
-
dist
|
|
93
|
-
|
|
94
|
-
# Gatsby files
|
|
95
|
-
.cache/
|
|
96
|
-
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
97
|
-
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
98
|
-
# public
|
|
99
|
-
|
|
100
|
-
# vuepress build output
|
|
101
|
-
.vuepress/dist
|
|
102
|
-
|
|
103
|
-
# vuepress v2.x temp and cache directory
|
|
104
|
-
.temp
|
|
105
|
-
.cache
|
|
106
|
-
|
|
107
|
-
# Docusaurus cache and generated files
|
|
108
|
-
.docusaurus
|
|
109
|
-
|
|
110
|
-
# Serverless directories
|
|
111
|
-
.serverless/
|
|
112
|
-
|
|
113
|
-
# FuseBox cache
|
|
114
|
-
.fusebox/
|
|
115
|
-
|
|
116
|
-
# DynamoDB Local files
|
|
117
|
-
.dynamodb/
|
|
118
|
-
|
|
119
|
-
# TernJS port file
|
|
120
|
-
.tern-port
|
|
121
|
-
|
|
122
|
-
# Stores VSCode versions used for testing VSCode extensions
|
|
123
|
-
.vscode-test
|
|
124
|
-
|
|
125
|
-
# yarn v2
|
|
126
|
-
.yarn/cache
|
|
127
|
-
.yarn/unplugged
|
|
128
|
-
.yarn/build-state.yml
|
|
129
|
-
.yarn/install-state.gz
|
|
130
|
-
.pnp.*
|
|
131
|
-
|
|
132
|
-
playground
|
|
133
|
-
|
|
134
|
-
.DS_Store
|
|
135
|
-
.vercel
|
|
136
|
-
|
|
137
|
-
.npmrc
|
|
138
|
-
.turbo
|
|
139
|
-
|
|
140
|
-
# Baseplate build artifacts
|
|
141
|
-
baseplate/.build
|
package/templates/.pnpmfile.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Prevents publish from any branch other than main
|
|
2
|
-
publish-branch=main
|
|
3
|
-
# Saves exact versions of dependencies by default
|
|
4
|
-
save-prefix=""
|
|
5
|
-
# Ensures we use locally linked packages when available
|
|
6
|
-
link-workspace-packages=true
|
|
7
|
-
# Defaults to saving as workspace:*
|
|
8
|
-
save-workspace-protocol=rolling
|
|
9
|
-
# Security setting to delay installation of newly released dependencies
|
|
10
|
-
# to reduce risk of installing compromised packages. Popular packages that are
|
|
11
|
-
# successfully attacked are often discovered and removed from the registry
|
|
12
|
-
# within an hour. Setting to 1440 minutes (24 hours) ensures only packages
|
|
13
|
-
# released at least one day ago can be installed.
|
|
14
|
-
minimumReleaseAge=1440
|
package/templates/README.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Baseplate Project
|
|
2
|
-
|
|
3
|
-
Welcome to your new Baseplate project! This README provides essential information on how to get started with your project, including setting up the generator UI and beginning your development process.
|
|
4
|
-
|
|
5
|
-
## Getting Started
|
|
6
|
-
|
|
7
|
-
To begin using the project, you will need to set up your local environment. Follow these instructions to get everything up and running.
|
|
8
|
-
|
|
9
|
-
### Prerequisites
|
|
10
|
-
|
|
11
|
-
Before you start, ensure you have `pnpm` installed on your system. If you do not have `pnpm` installed, you can learn how to install it by visiting [pnpm installation guide](https://pnpm.io/installation).
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
14
|
-
|
|
15
|
-
To install the necessary dependencies for your project, run the following command in the root directory of your project:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
pnpm install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Launching the Generator UI
|
|
22
|
-
|
|
23
|
-
To start the generator UI, which allows you to configure and initiate the code generation process, execute the following command:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pnpm baseplate serve
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
This command will start the server and open the corresponding web interface where you can customize your project’s specifications and features and generate the code.
|
|
30
|
-
|
|
31
|
-
## Configuration
|
|
32
|
-
|
|
33
|
-
To configure your project settings, use the web interface launched by the above command. Here you can specify data models, authentication mechanisms, and other project-specific settings.
|
|
34
|
-
|
|
35
|
-
Thank you for choosing Baseplate for your project’s foundation!
|