@baseplate-dev/create-project 0.3.3 → 0.6.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/CHANGELOG.md +338 -0
- package/LICENSE +114 -123
- package/dist/create-baseplate-project.js +4 -4
- package/dist/project-creator.js +23 -55
- package/dist/project-generator.d.ts +35 -0
- package/dist/project-generator.js +78 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +10 -21
- package/package.json +23 -20
- package/dist/exec.d.ts +0 -1
- package/dist/exec.js +0 -16
- package/dist/npm.service.d.ts +0 -1
- package/dist/npm.service.js +0 -20
- package/templates/.gitignore +0 -141
- package/templates/.pnpmfile.cjs +0 -2
- package/templates/.template.npmrc +0 -8
- package/templates/README.md +0 -35
- package/templates/scripts/setup-npmrc.cjs +0 -74
package/LICENSE
CHANGED
|
@@ -7,30 +7,30 @@ This project is licensed under the Mozilla Public License 2.0 (MPL-2.0) with the
|
|
|
7
7
|
**Generated Code Exception**: All code generated by Baseplate generators and templates belongs entirely to the user who generated it. Half Dome Labs LLC disclaims any copyright interest in generated code. Users may use, modify, distribute, and license generated code under any terms they choose, including proprietary licenses, with no restrictions or attribution requirements.
|
|
8
8
|
|
|
9
9
|
# Mozilla Public License Version 2.0
|
|
10
|
+
==================================
|
|
10
11
|
|
|
11
12
|
1. Definitions
|
|
12
|
-
|
|
13
|
-
---
|
|
13
|
+
--------------
|
|
14
14
|
|
|
15
15
|
1.1. "Contributor"
|
|
16
|
-
means each individual or legal entity that creates, contributes to
|
|
17
|
-
the creation of, or owns Covered Software.
|
|
16
|
+
means each individual or legal entity that creates, contributes to
|
|
17
|
+
the creation of, or owns Covered Software.
|
|
18
18
|
|
|
19
19
|
1.2. "Contributor Version"
|
|
20
|
-
means the combination of the Contributions of others (if any) used
|
|
21
|
-
by a Contributor and that particular Contributor's Contribution.
|
|
20
|
+
means the combination of the Contributions of others (if any) used
|
|
21
|
+
by a Contributor and that particular Contributor's Contribution.
|
|
22
22
|
|
|
23
23
|
1.3. "Contribution"
|
|
24
|
-
means Covered Software of a particular Contributor.
|
|
24
|
+
means Covered Software of a particular Contributor.
|
|
25
25
|
|
|
26
26
|
1.4. "Covered Software"
|
|
27
|
-
means Source Code Form to which the initial Contributor has attached
|
|
28
|
-
the notice in Exhibit A, the Executable Form of such Source Code
|
|
29
|
-
Form, and Modifications of such Source Code Form, in each case
|
|
30
|
-
including portions thereof.
|
|
27
|
+
means Source Code Form to which the initial Contributor has attached
|
|
28
|
+
the notice in Exhibit A, the Executable Form of such Source Code
|
|
29
|
+
Form, and Modifications of such Source Code Form, in each case
|
|
30
|
+
including portions thereof.
|
|
31
31
|
|
|
32
32
|
1.5. "Incompatible With Secondary Licenses"
|
|
33
|
-
means
|
|
33
|
+
means
|
|
34
34
|
|
|
35
35
|
(a) that the initial Contributor has attached the notice described
|
|
36
36
|
in Exhibit B to the Covered Software; or
|
|
@@ -40,22 +40,22 @@ means
|
|
|
40
40
|
terms of a Secondary License.
|
|
41
41
|
|
|
42
42
|
1.6. "Executable Form"
|
|
43
|
-
means any form of the work other than Source Code Form.
|
|
43
|
+
means any form of the work other than Source Code Form.
|
|
44
44
|
|
|
45
45
|
1.7. "Larger Work"
|
|
46
|
-
means a work that combines Covered Software with other material, in
|
|
47
|
-
a separate file or files, that is not Covered Software.
|
|
46
|
+
means a work that combines Covered Software with other material, in
|
|
47
|
+
a separate file or files, that is not Covered Software.
|
|
48
48
|
|
|
49
49
|
1.8. "License"
|
|
50
|
-
means this document.
|
|
50
|
+
means this document.
|
|
51
51
|
|
|
52
52
|
1.9. "Licensable"
|
|
53
|
-
means having the right to grant, to the maximum extent possible,
|
|
54
|
-
whether at the time of the initial grant or subsequently, any and
|
|
55
|
-
all of the rights conveyed by this License.
|
|
53
|
+
means having the right to grant, to the maximum extent possible,
|
|
54
|
+
whether at the time of the initial grant or subsequently, any and
|
|
55
|
+
all of the rights conveyed by this License.
|
|
56
56
|
|
|
57
57
|
1.10. "Modifications"
|
|
58
|
-
means any of the following:
|
|
58
|
+
means any of the following:
|
|
59
59
|
|
|
60
60
|
(a) any file in Source Code Form that results from an addition to,
|
|
61
61
|
deletion from, or modification of the contents of Covered
|
|
@@ -65,35 +65,34 @@ means any of the following:
|
|
|
65
65
|
Software.
|
|
66
66
|
|
|
67
67
|
1.11. "Patent Claims" of a Contributor
|
|
68
|
-
means any patent claim(s), including without limitation, method,
|
|
69
|
-
process, and apparatus claims, in any patent Licensable by such
|
|
70
|
-
Contributor that would be infringed, but for the grant of the
|
|
71
|
-
License, by the making, using, selling, offering for sale, having
|
|
72
|
-
made, import, or transfer of either its Contributions or its
|
|
73
|
-
Contributor Version.
|
|
68
|
+
means any patent claim(s), including without limitation, method,
|
|
69
|
+
process, and apparatus claims, in any patent Licensable by such
|
|
70
|
+
Contributor that would be infringed, but for the grant of the
|
|
71
|
+
License, by the making, using, selling, offering for sale, having
|
|
72
|
+
made, import, or transfer of either its Contributions or its
|
|
73
|
+
Contributor Version.
|
|
74
74
|
|
|
75
75
|
1.12. "Secondary License"
|
|
76
|
-
means either the GNU General Public License, Version 2.0, the GNU
|
|
77
|
-
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
78
|
-
Public License, Version 3.0, or any later versions of those
|
|
79
|
-
licenses.
|
|
76
|
+
means either the GNU General Public License, Version 2.0, the GNU
|
|
77
|
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
78
|
+
Public License, Version 3.0, or any later versions of those
|
|
79
|
+
licenses.
|
|
80
80
|
|
|
81
81
|
1.13. "Source Code Form"
|
|
82
|
-
means the form of the work preferred for making modifications.
|
|
82
|
+
means the form of the work preferred for making modifications.
|
|
83
83
|
|
|
84
84
|
1.14. "You" (or "Your")
|
|
85
|
-
means an individual or a legal entity exercising rights under this
|
|
86
|
-
License. For legal entities, "You" includes any entity that
|
|
87
|
-
controls, is controlled by, or is under common control with You. For
|
|
88
|
-
purposes of this definition, "control" means (a) the power, direct
|
|
89
|
-
or indirect, to cause the direction or management of such entity,
|
|
90
|
-
whether by contract or otherwise, or (b) ownership of more than
|
|
91
|
-
fifty percent (50%) of the outstanding shares or beneficial
|
|
92
|
-
ownership of such entity.
|
|
85
|
+
means an individual or a legal entity exercising rights under this
|
|
86
|
+
License. For legal entities, "You" includes any entity that
|
|
87
|
+
controls, is controlled by, or is under common control with You. For
|
|
88
|
+
purposes of this definition, "control" means (a) the power, direct
|
|
89
|
+
or indirect, to cause the direction or management of such entity,
|
|
90
|
+
whether by contract or otherwise, or (b) ownership of more than
|
|
91
|
+
fifty percent (50%) of the outstanding shares or beneficial
|
|
92
|
+
ownership of such entity.
|
|
93
93
|
|
|
94
94
|
2. License Grants and Conditions
|
|
95
|
-
|
|
96
|
-
---
|
|
95
|
+
--------------------------------
|
|
97
96
|
|
|
98
97
|
2.1. Grants
|
|
99
98
|
|
|
@@ -101,14 +100,14 @@ Each Contributor hereby grants You a world-wide, royalty-free,
|
|
|
101
100
|
non-exclusive license:
|
|
102
101
|
|
|
103
102
|
(a) under intellectual property rights (other than patent or trademark)
|
|
104
|
-
Licensable by such Contributor to use, reproduce, make available,
|
|
105
|
-
modify, display, perform, distribute, and otherwise exploit its
|
|
106
|
-
Contributions, either on an unmodified basis, with Modifications, or
|
|
107
|
-
as part of a Larger Work; and
|
|
103
|
+
Licensable by such Contributor to use, reproduce, make available,
|
|
104
|
+
modify, display, perform, distribute, and otherwise exploit its
|
|
105
|
+
Contributions, either on an unmodified basis, with Modifications, or
|
|
106
|
+
as part of a Larger Work; and
|
|
108
107
|
|
|
109
108
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
110
|
-
for sale, have made, import, and otherwise transfer either its
|
|
111
|
-
Contributions or its Contributor Version.
|
|
109
|
+
for sale, have made, import, and otherwise transfer either its
|
|
110
|
+
Contributions or its Contributor Version.
|
|
112
111
|
|
|
113
112
|
2.2. Effective Date
|
|
114
113
|
|
|
@@ -125,15 +124,15 @@ Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
|
125
124
|
Contributor:
|
|
126
125
|
|
|
127
126
|
(a) for any code that a Contributor has removed from Covered Software;
|
|
128
|
-
or
|
|
127
|
+
or
|
|
129
128
|
|
|
130
129
|
(b) for infringements caused by: (i) Your and any other third party's
|
|
131
|
-
modifications of Covered Software, or (ii) the combination of its
|
|
132
|
-
Contributions with other software (except as part of its Contributor
|
|
133
|
-
Version); or
|
|
130
|
+
modifications of Covered Software, or (ii) the combination of its
|
|
131
|
+
Contributions with other software (except as part of its Contributor
|
|
132
|
+
Version); or
|
|
134
133
|
|
|
135
134
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
136
|
-
its Contributions.
|
|
135
|
+
its Contributions.
|
|
137
136
|
|
|
138
137
|
This License does not grant any rights in the trademarks, service marks,
|
|
139
138
|
or logos of any Contributor (except as may be necessary to comply with
|
|
@@ -164,8 +163,7 @@ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
|
164
163
|
in Section 2.1.
|
|
165
164
|
|
|
166
165
|
3. Responsibilities
|
|
167
|
-
|
|
168
|
-
---
|
|
166
|
+
-------------------
|
|
169
167
|
|
|
170
168
|
3.1. Distribution of Source Form
|
|
171
169
|
|
|
@@ -182,15 +180,15 @@ Form.
|
|
|
182
180
|
If You distribute Covered Software in Executable Form then:
|
|
183
181
|
|
|
184
182
|
(a) such Covered Software must also be made available in Source Code
|
|
185
|
-
Form, as described in Section 3.1, and You must inform recipients of
|
|
186
|
-
the Executable Form how they can obtain a copy of such Source Code
|
|
187
|
-
Form by reasonable means in a timely manner, at a charge no more
|
|
188
|
-
than the cost of distribution to the recipient; and
|
|
183
|
+
Form, as described in Section 3.1, and You must inform recipients of
|
|
184
|
+
the Executable Form how they can obtain a copy of such Source Code
|
|
185
|
+
Form by reasonable means in a timely manner, at a charge no more
|
|
186
|
+
than the cost of distribution to the recipient; and
|
|
189
187
|
|
|
190
188
|
(b) You may distribute such Executable Form under the terms of this
|
|
191
|
-
License, or sublicense it under different terms, provided that the
|
|
192
|
-
license for the Executable Form does not attempt to limit or alter
|
|
193
|
-
the recipients' rights in the Source Code Form under this License.
|
|
189
|
+
License, or sublicense it under different terms, provided that the
|
|
190
|
+
license for the Executable Form does not attempt to limit or alter
|
|
191
|
+
the recipients' rights in the Source Code Form under this License.
|
|
194
192
|
|
|
195
193
|
3.3. Distribution of a Larger Work
|
|
196
194
|
|
|
@@ -227,8 +225,7 @@ disclaimers of warranty and limitations of liability specific to any
|
|
|
227
225
|
jurisdiction.
|
|
228
226
|
|
|
229
227
|
4. Inability to Comply Due to Statute or Regulation
|
|
230
|
-
|
|
231
|
-
---
|
|
228
|
+
---------------------------------------------------
|
|
232
229
|
|
|
233
230
|
If it is impossible for You to comply with any of the terms of this
|
|
234
231
|
License with respect to some or all of the Covered Software due to
|
|
@@ -241,8 +238,7 @@ or regulation, such description must be sufficiently detailed for a
|
|
|
241
238
|
recipient of ordinary skill to be able to understand it.
|
|
242
239
|
|
|
243
240
|
5. Termination
|
|
244
|
-
|
|
245
|
-
---
|
|
241
|
+
--------------
|
|
246
242
|
|
|
247
243
|
5.1. The rights granted under this License will terminate automatically
|
|
248
244
|
if You fail to comply with any of its terms. However, if You become
|
|
@@ -270,55 +266,50 @@ end user license agreements (excluding distributors and resellers) which
|
|
|
270
266
|
have been validly granted by You or Your distributors under this License
|
|
271
267
|
prior to termination shall survive termination.
|
|
272
268
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
- limitation may not apply to You. \*
|
|
315
|
-
- *
|
|
316
|
-
|
|
317
|
-
---
|
|
269
|
+
************************************************************************
|
|
270
|
+
* *
|
|
271
|
+
* 6. Disclaimer of Warranty *
|
|
272
|
+
* ------------------------- *
|
|
273
|
+
* *
|
|
274
|
+
* Covered Software is provided under this License on an "as is" *
|
|
275
|
+
* basis, without warranty of any kind, either expressed, implied, or *
|
|
276
|
+
* statutory, including, without limitation, warranties that the *
|
|
277
|
+
* Covered Software is free of defects, merchantable, fit for a *
|
|
278
|
+
* particular purpose or non-infringing. The entire risk as to the *
|
|
279
|
+
* quality and performance of the Covered Software is with You. *
|
|
280
|
+
* Should any Covered Software prove defective in any respect, You *
|
|
281
|
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
282
|
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
283
|
+
* essential part of this License. No use of any Covered Software is *
|
|
284
|
+
* authorized under this License except under this disclaimer. *
|
|
285
|
+
* *
|
|
286
|
+
************************************************************************
|
|
287
|
+
|
|
288
|
+
************************************************************************
|
|
289
|
+
* *
|
|
290
|
+
* 7. Limitation of Liability *
|
|
291
|
+
* -------------------------- *
|
|
292
|
+
* *
|
|
293
|
+
* Under no circumstances and under no legal theory, whether tort *
|
|
294
|
+
* (including negligence), contract, or otherwise, shall any *
|
|
295
|
+
* Contributor, or anyone who distributes Covered Software as *
|
|
296
|
+
* permitted above, be liable to You for any direct, indirect, *
|
|
297
|
+
* special, incidental, or consequential damages of any character *
|
|
298
|
+
* including, without limitation, damages for lost profits, loss of *
|
|
299
|
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
300
|
+
* and all other commercial damages or losses, even if such party *
|
|
301
|
+
* shall have been informed of the possibility of such damages. This *
|
|
302
|
+
* limitation of liability shall not apply to liability for death or *
|
|
303
|
+
* personal injury resulting from such party's negligence to the *
|
|
304
|
+
* extent applicable law prohibits such limitation. Some *
|
|
305
|
+
* jurisdictions do not allow the exclusion or limitation of *
|
|
306
|
+
* incidental or consequential damages, so this exclusion and *
|
|
307
|
+
* limitation may not apply to You. *
|
|
308
|
+
* *
|
|
309
|
+
************************************************************************
|
|
318
310
|
|
|
319
311
|
8. Litigation
|
|
320
|
-
|
|
321
|
-
---
|
|
312
|
+
-------------
|
|
322
313
|
|
|
323
314
|
Any litigation relating to this License may be brought only in the
|
|
324
315
|
courts of a jurisdiction where the defendant maintains its principal
|
|
@@ -328,8 +319,7 @@ Nothing in this Section shall prevent a party's ability to bring
|
|
|
328
319
|
cross-claims or counter-claims.
|
|
329
320
|
|
|
330
321
|
9. Miscellaneous
|
|
331
|
-
|
|
332
|
-
---
|
|
322
|
+
----------------
|
|
333
323
|
|
|
334
324
|
This License represents the complete agreement concerning the subject
|
|
335
325
|
matter hereof. If any provision of this License is held to be
|
|
@@ -339,8 +329,7 @@ that the language of a contract shall be construed against the drafter
|
|
|
339
329
|
shall not be used to construe this License against a Contributor.
|
|
340
330
|
|
|
341
331
|
10. Versions of the License
|
|
342
|
-
|
|
343
|
-
---
|
|
332
|
+
---------------------------
|
|
344
333
|
|
|
345
334
|
10.1. New Versions
|
|
346
335
|
|
|
@@ -371,11 +360,12 @@ If You choose to distribute Source Code Form that is Incompatible With
|
|
|
371
360
|
Secondary Licenses under the terms of this version of the License, the
|
|
372
361
|
notice described in Exhibit B of this License must be attached.
|
|
373
362
|
|
|
374
|
-
|
|
363
|
+
Exhibit A - Source Code Form License Notice
|
|
364
|
+
-------------------------------------------
|
|
375
365
|
|
|
376
|
-
This Source Code Form is subject to the terms of the Mozilla Public
|
|
377
|
-
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
378
|
-
file, You can obtain one at
|
|
366
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
367
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
368
|
+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
379
369
|
|
|
380
370
|
If it is not possible or desirable to put the notice in a particular
|
|
381
371
|
file, then You may include the notice in a location (such as a LICENSE
|
|
@@ -384,7 +374,8 @@ for such a notice.
|
|
|
384
374
|
|
|
385
375
|
You may add additional accurate notices of copyright ownership.
|
|
386
376
|
|
|
387
|
-
|
|
377
|
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
378
|
+
---------------------------------------------------------
|
|
388
379
|
|
|
389
|
-
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
390
|
-
defined by the Mozilla Public License, v. 2.0.
|
|
380
|
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
381
|
+
defined by the Mozilla Public License, v. 2.0.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { getPackageVersion } from '@baseplate-dev/utils/node';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import { program } from 'commander';
|
|
4
5
|
import fs from 'node:fs/promises';
|
|
5
6
|
import path from 'node:path';
|
|
6
|
-
import { getLatestCliVersion } from './npm.service.js';
|
|
7
7
|
import { generateBaseplateProject } from './project-creator.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getCliVersion } from './version.js';
|
|
9
9
|
// check if directory contains a package.json file
|
|
10
10
|
async function checkForPackageJson(directory) {
|
|
11
11
|
try {
|
|
@@ -18,7 +18,7 @@ async function checkForPackageJson(directory) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
async function runMain() {
|
|
21
|
-
const version = await getPackageVersion();
|
|
21
|
+
const version = await getPackageVersion(import.meta.dirname);
|
|
22
22
|
if (!version) {
|
|
23
23
|
throw new Error('Could not determine package version');
|
|
24
24
|
}
|
|
@@ -44,7 +44,7 @@ async function runMain() {
|
|
|
44
44
|
if (hasPackageJson) {
|
|
45
45
|
throw new Error(`The directory ${directory} already contains a package.json file.`);
|
|
46
46
|
}
|
|
47
|
-
const cliVersion = await
|
|
47
|
+
const cliVersion = await getCliVersion();
|
|
48
48
|
await generateBaseplateProject({
|
|
49
49
|
packageName,
|
|
50
50
|
directory: resolvedDirectory,
|
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.6.5',
|
|
44
|
-
engines: {
|
|
45
|
-
node: '^22.0.0',
|
|
46
|
-
pnpm: '^10.6.0',
|
|
47
|
-
},
|
|
48
|
-
volta: {
|
|
49
|
-
node: '22.14.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,78 @@
|
|
|
1
|
+
import { getLatestMigrationVersion } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { generateProjectId, SERVER_CORE_MODULES, 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
|
+
libraries: [],
|
|
27
|
+
models: [],
|
|
28
|
+
isInitialized: false,
|
|
29
|
+
schemaVersion: getLatestMigrationVersion(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generates the root package files using the Baseplate sync engine.
|
|
34
|
+
* This creates all standard root-level files (package.json, turbo.json, etc.)
|
|
35
|
+
* and writes the project definition to baseplate/project-definition.json.
|
|
36
|
+
*
|
|
37
|
+
* @param config - Configuration for the initial project
|
|
38
|
+
*/
|
|
39
|
+
export async function generateRootPackage(config) {
|
|
40
|
+
const definition = createInitialProjectDefinition(config);
|
|
41
|
+
const logger = createConsoleLogger('error');
|
|
42
|
+
// Create project directory and write project definition first
|
|
43
|
+
// This is needed because syncProject expects the definition to exist on disk
|
|
44
|
+
const baseplateDir = path.join(config.directory, 'baseplate');
|
|
45
|
+
await fs.mkdir(baseplateDir, { recursive: true });
|
|
46
|
+
await fs.writeFile(path.join(baseplateDir, 'project-definition.json'), stringifyPrettyStable(definition));
|
|
47
|
+
// Create minimal plugin store (no plugins for initial project)
|
|
48
|
+
const pluginStore = {
|
|
49
|
+
availablePlugins: [],
|
|
50
|
+
coreModules: SERVER_CORE_MODULES,
|
|
51
|
+
};
|
|
52
|
+
// Create parser context
|
|
53
|
+
const context = {
|
|
54
|
+
pluginStore,
|
|
55
|
+
cliVersion: config.cliVersion,
|
|
56
|
+
project: {
|
|
57
|
+
id: generateProjectId(config.directory),
|
|
58
|
+
name: config.name,
|
|
59
|
+
directory: config.directory,
|
|
60
|
+
type: 'user',
|
|
61
|
+
baseplateDirectory: path.join(config.directory, 'baseplate'),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
// Create sync metadata controller to set up .baseplate directory
|
|
65
|
+
const syncMetadataController = new SyncMetadataController(config.directory, logger);
|
|
66
|
+
// Use syncProject to generate all files and set up metadata
|
|
67
|
+
const result = await syncProject({
|
|
68
|
+
directory: config.directory,
|
|
69
|
+
logger,
|
|
70
|
+
context,
|
|
71
|
+
userConfig: {},
|
|
72
|
+
syncMetadataController,
|
|
73
|
+
overwrite: true,
|
|
74
|
+
});
|
|
75
|
+
if (result.status === 'error') {
|
|
76
|
+
throw new Error('Failed to generate project files');
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getCliVersion(): Promise<string>;
|
package/dist/version.js
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
if (packageJsonPath) {
|
|
12
|
-
// Read the package.json file.
|
|
13
|
-
const fileContent = await fs.readFile(packageJsonPath, 'utf8');
|
|
14
|
-
const packageJson = JSON.parse(fileContent);
|
|
15
|
-
// Return the version.
|
|
16
|
-
cachedVersion = packageJson.version || null;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
cachedVersion = null;
|
|
20
|
-
}
|
|
1
|
+
import { getPackageVersion } from '@baseplate-dev/utils/node';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export async function getCliVersion() {
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const cliEntryPath = require.resolve('@baseplate-dev/project-builder-cli');
|
|
7
|
+
const version = await getPackageVersion(path.dirname(cliEntryPath));
|
|
8
|
+
if (!version) {
|
|
9
|
+
throw new Error(`Unable to find version in package.json for @baseplate-dev/project-builder-cli in ${cliEntryPath}`);
|
|
21
10
|
}
|
|
22
|
-
return
|
|
11
|
+
return version;
|
|
23
12
|
}
|