@baseplate-dev/create-project 0.1.1 → 0.1.3
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/README.md +3 -3
- package/bin/create-baseplate-project.js +3 -0
- package/dist/create-baseplate-project.js +2 -4
- package/dist/exec.d.ts +1 -0
- package/dist/exec.js +16 -0
- package/dist/npm.service.d.ts +1 -4
- package/dist/npm.service.js +5 -51
- package/dist/project-creator.d.ts +1 -2
- package/dist/project-creator.js +5 -13
- package/package.json +13 -9
- package/templates/.template.npmrc +0 -2
- package/templates/README.md +0 -13
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
The Create Baseplate package provides a straightforward method for initiating a new Baseplate project, automatically generating all necessary files within your project directory. Baseplate is a full-stack application generator, laying the groundwork for scalable and maintainable development.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
> **⚠️ WARNING: PRE-RELEASE VERSION**
|
|
6
|
+
>
|
|
7
|
+
> This project is still in early development. While it's now open source and available for experimentation, it's not yet ready for production use. The API and features may change significantly before the stable release.
|
|
8
8
|
|
|
9
9
|
## Creating a Project
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import { program } from 'commander';
|
|
4
4
|
import fs from 'node:fs/promises';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import {
|
|
6
|
+
import { getLatestCliVersion } from './npm.service.js';
|
|
7
7
|
import { generateBaseplateProject } from './project-creator.js';
|
|
8
8
|
import { getPackageVersion } from './version.js';
|
|
9
9
|
// check if directory contains a package.json file
|
|
@@ -44,12 +44,10 @@ async function runMain() {
|
|
|
44
44
|
if (hasPackageJson) {
|
|
45
45
|
throw new Error(`The directory ${directory} already contains a package.json file.`);
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
const { npmToken, cliVersion } = await getNpmTokenAndVersion();
|
|
47
|
+
const cliVersion = await getLatestCliVersion();
|
|
49
48
|
await generateBaseplateProject({
|
|
50
49
|
packageName,
|
|
51
50
|
directory: resolvedDirectory,
|
|
52
|
-
npmToken,
|
|
53
51
|
cliVersion,
|
|
54
52
|
});
|
|
55
53
|
}
|
package/dist/exec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function exec(command: string, cwd?: string): Promise<void>;
|
package/dist/exec.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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/dist/npm.service.d.ts
CHANGED
package/dist/npm.service.js
CHANGED
|
@@ -1,66 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import axios, { AxiosError } from 'axios';
|
|
1
|
+
import axios from 'axios';
|
|
3
2
|
import ora from 'ora';
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super('API token appears invalid');
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
async function fetchNpmPackageVersion(token) {
|
|
3
|
+
export async function getLatestCliVersion() {
|
|
10
4
|
const spinner = ora({
|
|
11
5
|
text: 'Checking for the latest version of Baseplate CLI...',
|
|
12
6
|
}).start();
|
|
13
7
|
try {
|
|
14
8
|
const url = `https://registry.npmjs.org/@baseplate-dev/project-builder-cli`;
|
|
15
|
-
const
|
|
16
|
-
Authorization: `Bearer ${token}`,
|
|
17
|
-
};
|
|
18
|
-
const response = await axios.get(url, { headers });
|
|
9
|
+
const response = await axios.get(url);
|
|
19
10
|
if (!response.data.name) {
|
|
20
11
|
throw new Error('Invalid response from NPM registry');
|
|
21
12
|
}
|
|
22
13
|
spinner.succeed();
|
|
23
14
|
return response.data['dist-tags'].latest;
|
|
24
15
|
}
|
|
25
|
-
catch
|
|
26
|
-
|
|
27
|
-
spinner.fail('Your NPM token appears invalid. Please try again with a valid token.\n');
|
|
28
|
-
throw new InvalidTokenError();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
if (spinner.isSpinning) {
|
|
33
|
-
spinner.fail();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export async function getNpmTokenAndVersion() {
|
|
38
|
-
const NPM_TOKEN_REGEX = /^npm_[\w-]{10,100}$/;
|
|
39
|
-
let latestVersion;
|
|
40
|
-
let npmToken;
|
|
41
|
-
while (true) {
|
|
42
|
-
npmToken = await input({
|
|
43
|
-
message: 'NPM Token',
|
|
44
|
-
validate: (input) => {
|
|
45
|
-
if (!NPM_TOKEN_REGEX.test(input)) {
|
|
46
|
-
return 'Please enter a valid NPM token';
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
try {
|
|
52
|
-
console.info('');
|
|
53
|
-
latestVersion = await fetchNpmPackageVersion(npmToken);
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
if (!(error instanceof InvalidTokenError)) {
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (!latestVersion) {
|
|
16
|
+
catch {
|
|
17
|
+
spinner.fail('Failed to fetch the latest CLI version');
|
|
63
18
|
throw new Error('Could not determine the latest version of Baseplate CLI');
|
|
64
19
|
}
|
|
65
|
-
return { npmToken, cliVersion: latestVersion };
|
|
66
20
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare function generateBaseplateProject({ packageName, directory,
|
|
1
|
+
export declare function generateBaseplateProject({ packageName, directory, cliVersion, }: {
|
|
2
2
|
packageName: string;
|
|
3
3
|
directory: string;
|
|
4
|
-
npmToken: string;
|
|
5
4
|
cliVersion: string;
|
|
6
5
|
}): Promise<void>;
|
package/dist/project-creator.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { execa } from 'execa';
|
|
3
2
|
import fs from 'node:fs/promises';
|
|
4
3
|
import path from 'node:path';
|
|
5
4
|
import ora from 'ora';
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { exec } from './exec.js';
|
|
6
|
+
export async function generateBaseplateProject({ packageName, directory, cliVersion, }) {
|
|
7
|
+
const spinner = ora({
|
|
8
8
|
text: 'Creating project files...',
|
|
9
9
|
}).start();
|
|
10
10
|
try {
|
|
@@ -50,18 +50,10 @@ export async function generateBaseplateProject({ packageName, directory, npmToke
|
|
|
50
50
|
},
|
|
51
51
|
}, null, 2));
|
|
52
52
|
await copyFile('.gitignore', '.gitignore');
|
|
53
|
-
await copyFile('.
|
|
54
|
-
await copyFile('.template.npmrc', '.template.npmrc');
|
|
55
|
-
await copyFile('scripts/setup-npmrc.cjs', 'scripts/setup-npmrc.cjs');
|
|
53
|
+
await copyFile('.template.npmrc', '.npmrc');
|
|
56
54
|
await copyFile('README.md', 'README.md');
|
|
57
|
-
await writeFile('.env', `NPM_TOKEN=${npmToken}\n`);
|
|
58
|
-
spinner.succeed();
|
|
59
|
-
spinner = ora({
|
|
60
|
-
text: 'Installing dependencies...',
|
|
61
|
-
}).start();
|
|
62
|
-
await execa({ cwd: directory }) `node .pnpmfile.cjs --silent`;
|
|
63
|
-
await execa({ cwd: directory }) `pnpm install`;
|
|
64
55
|
spinner.succeed();
|
|
56
|
+
await exec('pnpm install', directory);
|
|
65
57
|
const relativePath = path.relative(process.cwd(), directory);
|
|
66
58
|
console.info('');
|
|
67
59
|
console.info(`
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baseplate-dev/create-project",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "CLI starter kit for creating a new Baseplate project",
|
|
5
|
+
"homepage": "https://www.baseplate.dev",
|
|
5
6
|
"repository": "https://github.com/halfdomelabs/baseplate",
|
|
6
|
-
"license": "
|
|
7
|
+
"license": "MPL-2.0",
|
|
7
8
|
"author": "Half Dome Labs LLC",
|
|
8
9
|
"type": "module",
|
|
9
10
|
"imports": {
|
|
@@ -12,32 +13,34 @@
|
|
|
12
13
|
"default": "./dist/*"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
|
-
"bin": "./
|
|
16
|
+
"bin": "./bin/create-baseplate-project.js",
|
|
16
17
|
"files": [
|
|
18
|
+
"README.md",
|
|
17
19
|
"LICENSE",
|
|
18
20
|
"CHANGELOG",
|
|
19
21
|
"dist/**/*",
|
|
20
|
-
"
|
|
21
|
-
"templates/**/*",
|
|
22
|
+
"!dist/**/*.d.ts.map",
|
|
22
23
|
"!dist/**/*.tsbuildinfo",
|
|
23
|
-
"
|
|
24
|
+
"templates/**/*",
|
|
25
|
+
"bin/**/*"
|
|
24
26
|
],
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@inquirer/prompts": "7.2.1",
|
|
27
28
|
"axios": "^1.8.3",
|
|
28
29
|
"chalk": "5.3.0",
|
|
29
30
|
"commander": "^12.1.0",
|
|
30
31
|
"execa": "9.3.0",
|
|
31
32
|
"ora": "^8.0.1",
|
|
32
|
-
"@baseplate-dev/utils": "0.1.
|
|
33
|
+
"@baseplate-dev/utils": "0.1.3"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/node": "^22.0.0",
|
|
36
37
|
"eslint": "9.26.0",
|
|
38
|
+
"memfs": "4.15.1",
|
|
37
39
|
"prettier": "3.5.3",
|
|
38
40
|
"tsx": "4.19.3",
|
|
39
41
|
"typescript": "5.7.3",
|
|
40
|
-
"
|
|
42
|
+
"vitest": "3.0.7",
|
|
43
|
+
"@baseplate-dev/tools": "0.1.3"
|
|
41
44
|
},
|
|
42
45
|
"engines": {
|
|
43
46
|
"node": "^22.0.0"
|
|
@@ -57,6 +60,7 @@
|
|
|
57
60
|
"prettier:check": "prettier --check .",
|
|
58
61
|
"prettier:write": "prettier -w .",
|
|
59
62
|
"start": "node ./dist/create-baseplate-project.js",
|
|
63
|
+
"test": "vitest",
|
|
60
64
|
"typecheck": "tsc --noEmit"
|
|
61
65
|
}
|
|
62
66
|
}
|
package/templates/README.md
CHANGED
|
@@ -10,19 +10,6 @@ To begin using the project, you will need to set up your local environment. Foll
|
|
|
10
10
|
|
|
11
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
12
|
|
|
13
|
-
### Environment Setup
|
|
14
|
-
|
|
15
|
-
For this project, you will need to set up environment variables that the application requires to function properly. One essential variable is `NPM_TOKEN`, which is used for accessing private npm packages. If you set this project up with the project creator, you should have already been asked for this token. Otherwise, to set this up:
|
|
16
|
-
|
|
17
|
-
1. Create a `.env` file in the root directory of your project.
|
|
18
|
-
2. Add the following line to the `.env` file:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
NPM_TOKEN=<your-npm-token>
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
You can obtain the NPM token from your engineering manager.
|
|
25
|
-
|
|
26
13
|
### Installation
|
|
27
14
|
|
|
28
15
|
To install the necessary dependencies for your project, run the following command in the root directory of your project:
|