@pixpilot/scaffoldfy-configs 0.38.1 → 0.39.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/CHANGELOG.md +6 -0
- package/package.json +3 -3
- package/test/workspace-package-generator.test.ts +81 -6
- package/workspace-package-generator/scaffoldfy-base.json +29 -4
- package/workspace-package-generator/scaffoldfy-project-info.json +1 -1
- package/workspace-package-generator/scaffoldfy.json +28 -2
- package/workspace-package-generator/templates/package.json.hbs +12 -11
- package/workspace-package-generator/templates/tsdown.config.ts.hbs +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/scaffoldfy-configs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.39.0",
|
|
5
5
|
"author": "PixPilot <m.doaie@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@types/node": "^22.18.11",
|
|
31
31
|
"eslint": "^9.38.0",
|
|
32
32
|
"@internal/eslint-config": "0.3.0",
|
|
33
|
-
"@internal/tsdown-config": "0.1.0",
|
|
34
33
|
"@internal/prettier-config": "0.0.1",
|
|
34
|
+
"@internal/tsdown-config": "0.1.0",
|
|
35
35
|
"@internal/vitest-config": "0.1.0",
|
|
36
|
-
"@pixpilot/scaffoldfy": "0.
|
|
36
|
+
"@pixpilot/scaffoldfy": "0.55.0"
|
|
37
37
|
},
|
|
38
38
|
"prettier": "@internal/prettier-config",
|
|
39
39
|
"publishConfig": {
|
|
@@ -88,6 +88,41 @@ describe('workspace-package-generator – schema', () => {
|
|
|
88
88
|
}
|
|
89
89
|
expect(result.valid).toBe(true);
|
|
90
90
|
});
|
|
91
|
+
|
|
92
|
+
it('should collect a registry choice for public packages', () => {
|
|
93
|
+
const configPath = path.join(CONFIG_DIR, 'scaffoldfy-base.json');
|
|
94
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as {
|
|
95
|
+
prompts: Array<{
|
|
96
|
+
id: string;
|
|
97
|
+
choices?: Array<{ name: string; value: string }>;
|
|
98
|
+
enabled?: { type: string; value: string };
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
const registryPrompt = config.prompts.find(
|
|
102
|
+
(prompt) => prompt.id === 'publishRegistry',
|
|
103
|
+
);
|
|
104
|
+
const customRegistryPrompt = config.prompts.find(
|
|
105
|
+
(prompt) => prompt.id === 'customRegistryUrl',
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(registryPrompt).toMatchObject({
|
|
109
|
+
enabled: {
|
|
110
|
+
type: 'condition',
|
|
111
|
+
value: 'isPublishablePackage === true && isPublicPackage === true',
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
expect(registryPrompt?.choices).toEqual([
|
|
115
|
+
{ name: 'GitHub Packages', value: 'github' },
|
|
116
|
+
{ name: 'npm', value: 'npm' },
|
|
117
|
+
{ name: 'Custom registry URL', value: 'custom' },
|
|
118
|
+
]);
|
|
119
|
+
expect(customRegistryPrompt).toMatchObject({
|
|
120
|
+
enabled: {
|
|
121
|
+
type: 'condition',
|
|
122
|
+
value: "publishRegistry === 'custom'",
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
});
|
|
91
126
|
});
|
|
92
127
|
|
|
93
128
|
/* -------------------------------------------------------------------------- */
|
|
@@ -180,7 +215,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
180
215
|
it('should render a valid JSON for an internal package', () => {
|
|
181
216
|
const ctx = {
|
|
182
217
|
packageBaseName: 'my-package',
|
|
183
|
-
|
|
218
|
+
isPublishablePackage: false,
|
|
184
219
|
workspace: 'packages',
|
|
185
220
|
repoDirectory: 'packages/my-package',
|
|
186
221
|
relativeRootPath: '../../',
|
|
@@ -191,6 +226,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
191
226
|
isBundlerTsdown: false,
|
|
192
227
|
hasTsdownConfig: false,
|
|
193
228
|
tsdownConfigPackage: '@pixpilot/tsdown-config',
|
|
229
|
+
publishRegistryUrl: 'https://registry.npmjs.org',
|
|
194
230
|
};
|
|
195
231
|
|
|
196
232
|
const rendered = renderHbs(tplPath, ctx);
|
|
@@ -214,7 +250,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
214
250
|
it('should render valid JSON for a public npm package (tsdown)', () => {
|
|
215
251
|
const ctx = {
|
|
216
252
|
packageBaseName: 'my-package',
|
|
217
|
-
|
|
253
|
+
isPublishablePackage: true,
|
|
218
254
|
isPublicPackage: true,
|
|
219
255
|
bundler: 'tsdown',
|
|
220
256
|
isBundlerTsc: false,
|
|
@@ -227,6 +263,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
227
263
|
author: 'Test Author',
|
|
228
264
|
repoUrl: 'https://github.com/test/monorepo.git',
|
|
229
265
|
packageOrgName: 'myorg',
|
|
266
|
+
publishRegistryUrl: 'https://registry.npmjs.org',
|
|
230
267
|
};
|
|
231
268
|
|
|
232
269
|
const rendered = renderHbs(tplPath, ctx);
|
|
@@ -236,6 +273,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
236
273
|
expect(pkg.private).toBeUndefined();
|
|
237
274
|
expect(pkg.sideEffects).toBe(false);
|
|
238
275
|
expect(pkg.publishConfig?.access).toBe('public');
|
|
276
|
+
expect(pkg.publishConfig?.registry).toBe('https://registry.npmjs.org');
|
|
239
277
|
expect(pkg.files).toContain('dist');
|
|
240
278
|
expect(pkg.scripts?.build).toBe('tsdown');
|
|
241
279
|
expect(pkg.devDependencies?.['@pixpilot/tsdown-config']).toBeDefined();
|
|
@@ -246,7 +284,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
246
284
|
it('should render valid JSON for a private npm package (tsc)', () => {
|
|
247
285
|
const ctx = {
|
|
248
286
|
packageBaseName: 'my-package',
|
|
249
|
-
|
|
287
|
+
isPublishablePackage: true,
|
|
250
288
|
isPublicPackage: false,
|
|
251
289
|
bundler: 'tsc',
|
|
252
290
|
isBundlerTsc: true,
|
|
@@ -259,6 +297,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
259
297
|
author: 'Test Author',
|
|
260
298
|
repoUrl: 'https://github.com/test/monorepo.git',
|
|
261
299
|
orgName: '',
|
|
300
|
+
publishRegistryUrl: 'https://registry.npmjs.org',
|
|
262
301
|
};
|
|
263
302
|
|
|
264
303
|
const rendered = renderHbs(tplPath, ctx);
|
|
@@ -266,16 +305,52 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
|
|
|
266
305
|
|
|
267
306
|
expect(pkg.name).toBe('my-package');
|
|
268
307
|
expect(pkg.publishConfig?.access).toBe('restricted');
|
|
308
|
+
expect(pkg.publishConfig?.registry).toBe('https://registry.npmjs.org');
|
|
269
309
|
expect(pkg.scripts?.build).toContain('tsc');
|
|
270
310
|
expect(pkg.scripts?.['build:watch']).toContain('tsc');
|
|
271
311
|
expect(pkg.devDependencies?.tsdown).toBeUndefined();
|
|
272
312
|
});
|
|
273
313
|
|
|
314
|
+
/** Private package for the Pixpilot organization */
|
|
315
|
+
it('should publish a Pixpilot private package through GitHub Packages', () => {
|
|
316
|
+
const ctx = {
|
|
317
|
+
packageBaseName: 'foo',
|
|
318
|
+
isPublishablePackage: true,
|
|
319
|
+
isPublicPackage: false,
|
|
320
|
+
isPixpilotPrivatePackage: true,
|
|
321
|
+
publishRegistryUrl: 'https://npm.pkg.github.com',
|
|
322
|
+
bundler: 'tsc',
|
|
323
|
+
isBundlerTsc: true,
|
|
324
|
+
isBundlerTsdown: false,
|
|
325
|
+
hasTsdownConfig: false,
|
|
326
|
+
tsdownConfigPackage: '@pixpilot/tsdown-config',
|
|
327
|
+
workspace: 'packages',
|
|
328
|
+
repoDirectory: 'packages/foo',
|
|
329
|
+
relativeRootPath: '../../',
|
|
330
|
+
author: 'Test Author',
|
|
331
|
+
repoUrl: 'https://github.com/pixpilot-private/your-repo.git',
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const rendered = renderHbs(tplPath, ctx);
|
|
335
|
+
const pkg = JSON.parse(rendered);
|
|
336
|
+
|
|
337
|
+
expect(pkg.name).toBe('@pixpilot-private/foo');
|
|
338
|
+
expect(pkg.publishConfig).toMatchObject({
|
|
339
|
+
access: 'restricted',
|
|
340
|
+
registry: 'https://npm.pkg.github.com',
|
|
341
|
+
});
|
|
342
|
+
expect(pkg.repository).toEqual({
|
|
343
|
+
type: 'git',
|
|
344
|
+
url: 'https://github.com/pixpilot-private/your-repo.git',
|
|
345
|
+
directory: 'packages/foo',
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
274
349
|
/** npm package with internal tsdown config */
|
|
275
350
|
it('should use @internal/tsdown-config when hasTsdownConfig is true', () => {
|
|
276
351
|
const ctx = {
|
|
277
352
|
packageBaseName: 'my-package',
|
|
278
|
-
|
|
353
|
+
isPublishablePackage: true,
|
|
279
354
|
isPublicPackage: true,
|
|
280
355
|
bundler: 'tsdown',
|
|
281
356
|
isBundlerTsc: false,
|
|
@@ -327,7 +402,7 @@ describe('workspace-package-generator – tsdown.config.ts.hbs rendering', () =>
|
|
|
327
402
|
it("should add platform: 'neutral' for an npm package", () => {
|
|
328
403
|
const ctx = {
|
|
329
404
|
tsdownConfigPackage: '@pixpilot/tsdown-config',
|
|
330
|
-
|
|
405
|
+
isPublishablePackage: true,
|
|
331
406
|
};
|
|
332
407
|
const rendered = renderHbs(tplPath, ctx);
|
|
333
408
|
|
|
@@ -337,7 +412,7 @@ describe('workspace-package-generator – tsdown.config.ts.hbs rendering', () =>
|
|
|
337
412
|
it("should not add platform: 'neutral' when not an npm package", () => {
|
|
338
413
|
const ctx = {
|
|
339
414
|
tsdownConfigPackage: '@pixpilot/tsdown-config',
|
|
340
|
-
|
|
415
|
+
isPublishablePackage: false,
|
|
341
416
|
};
|
|
342
417
|
const rendered = renderHbs(tplPath, ctx);
|
|
343
418
|
|
|
@@ -107,9 +107,9 @@
|
|
|
107
107
|
"required": false
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
|
-
"id": "
|
|
110
|
+
"id": "isPublishablePackage",
|
|
111
111
|
"type": "confirm",
|
|
112
|
-
"message": "
|
|
112
|
+
"message": "Should this package be published?",
|
|
113
113
|
"default": false
|
|
114
114
|
},
|
|
115
115
|
{
|
|
@@ -119,7 +119,32 @@
|
|
|
119
119
|
"default": false,
|
|
120
120
|
"enabled": {
|
|
121
121
|
"type": "condition",
|
|
122
|
-
"value": "
|
|
122
|
+
"value": "isPublishablePackage === true"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "publishRegistry",
|
|
127
|
+
"type": "select",
|
|
128
|
+
"message": "Select a registry for this public package",
|
|
129
|
+
"choices": [
|
|
130
|
+
{ "name": "GitHub Packages", "value": "github" },
|
|
131
|
+
{ "name": "npm", "value": "npm" },
|
|
132
|
+
{ "name": "Custom registry URL", "value": "custom" }
|
|
133
|
+
],
|
|
134
|
+
"default": "npm",
|
|
135
|
+
"enabled": {
|
|
136
|
+
"type": "condition",
|
|
137
|
+
"value": "isPublishablePackage === true && isPublicPackage === true"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"id": "customRegistryUrl",
|
|
142
|
+
"type": "input",
|
|
143
|
+
"message": "Enter the custom registry URL",
|
|
144
|
+
"required": true,
|
|
145
|
+
"enabled": {
|
|
146
|
+
"type": "condition",
|
|
147
|
+
"value": "publishRegistry === 'custom'"
|
|
123
148
|
}
|
|
124
149
|
},
|
|
125
150
|
{
|
|
@@ -133,7 +158,7 @@
|
|
|
133
158
|
"default": "tsc",
|
|
134
159
|
"enabled": {
|
|
135
160
|
"type": "condition",
|
|
136
|
-
"value": "
|
|
161
|
+
"value": "isPublishablePackage === true"
|
|
137
162
|
}
|
|
138
163
|
},
|
|
139
164
|
{
|
|
@@ -30,6 +30,32 @@
|
|
|
30
30
|
"value": "{{orgName}}"
|
|
31
31
|
},
|
|
32
32
|
"transformers": ["kebabcase"]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "isPixpilotPrivatePackage",
|
|
36
|
+
"value": {
|
|
37
|
+
"type": "conditional",
|
|
38
|
+
"condition": "isPublishablePackage === true && isPublicPackage === false && (repoOwner === 'pixpilot' || orgName === 'PixPilot' || orgName === 'pixpilot')",
|
|
39
|
+
"ifTrue": true,
|
|
40
|
+
"ifFalse": false
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "publishRegistryUrl",
|
|
45
|
+
"value": {
|
|
46
|
+
"type": "conditional",
|
|
47
|
+
"condition": "publishRegistry === 'github' || isPixpilotPrivatePackage === true",
|
|
48
|
+
"ifTrue": "https://npm.pkg.github.com",
|
|
49
|
+
"ifFalse": {
|
|
50
|
+
"type": "conditional",
|
|
51
|
+
"condition": "publishRegistry === 'custom'",
|
|
52
|
+
"ifTrue": {
|
|
53
|
+
"type": "interpolate",
|
|
54
|
+
"value": "{{customRegistryUrl}}"
|
|
55
|
+
},
|
|
56
|
+
"ifFalse": "https://registry.npmjs.org"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
33
59
|
}
|
|
34
60
|
],
|
|
35
61
|
|
|
@@ -89,7 +115,7 @@
|
|
|
89
115
|
"type": "create",
|
|
90
116
|
"enabled": {
|
|
91
117
|
"type": "condition",
|
|
92
|
-
"value": "bundler === 'tsc' &&
|
|
118
|
+
"value": "bundler === 'tsc' && isPublishablePackage === true"
|
|
93
119
|
},
|
|
94
120
|
"config": {
|
|
95
121
|
"file": "{{workspace}}/{{packageBaseName}}/tsconfig.build.json",
|
|
@@ -103,7 +129,7 @@
|
|
|
103
129
|
"type": "create",
|
|
104
130
|
"enabled": {
|
|
105
131
|
"type": "condition",
|
|
106
|
-
"value": "bundler === 'tsdown' &&
|
|
132
|
+
"value": "bundler === 'tsdown' && isPublishablePackage === true"
|
|
107
133
|
},
|
|
108
134
|
"config": {
|
|
109
135
|
"file": "{{workspace}}/{{packageBaseName}}/tsdown.config.ts",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "{{#if
|
|
2
|
+
"name": "{{#if isPublishablePackage}}{{#if isPublicPackage}}{{#if packageOrgName}}@{{packageOrgName}}/{{packageBaseName}}{{else}}{{packageBaseName}}{{/if}}{{else}}{{#if isPixpilotPrivatePackage}}@pixpilot-private/{{packageBaseName}}{{else}}{{#if packageOrgName}}@{{packageOrgName}}/{{packageBaseName}}{{else}}{{packageBaseName}}{{/if}}{{/if}}{{/if}}{{else}}@internal/{{packageBaseName}}{{/if}}",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "0.0.0",
|
|
5
|
-
{{#unless
|
|
5
|
+
{{#unless isPublishablePackage}}
|
|
6
6
|
"private": true,
|
|
7
7
|
{{/unless}}
|
|
8
8
|
"packageManager": "pnpm@10.17.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"url": "{{repoUrl}}",
|
|
20
20
|
"directory": "{{repoDirectory}}"
|
|
21
21
|
},
|
|
22
|
-
{{#if
|
|
22
|
+
{{#if isPublishablePackage}}
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
{{/if}}
|
|
25
25
|
"bugs": {
|
|
@@ -34,12 +34,13 @@
|
|
|
34
34
|
"react-dom": "^18 || ^19"
|
|
35
35
|
},
|
|
36
36
|
{{/if}}
|
|
37
|
-
{{#if
|
|
37
|
+
{{#if isPublishablePackage}}
|
|
38
38
|
"files": [
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "{{#if isPublicPackage}}public{{else}}restricted{{/if}}",
|
|
43
|
+
"registry": "{{publishRegistryUrl}}",
|
|
43
44
|
"exports": {
|
|
44
45
|
".": {
|
|
45
46
|
"types": "./dist/index.d.ts",
|
|
@@ -53,12 +54,12 @@
|
|
|
53
54
|
},
|
|
54
55
|
{{/if}}
|
|
55
56
|
"scripts": {
|
|
56
|
-
{{#if
|
|
57
|
+
{{#if isPublishablePackage}}
|
|
57
58
|
"prepublishOnly": "pnpm run clean && pnpm run build",
|
|
58
59
|
{{/if}}
|
|
59
60
|
"clean": "git clean -xdf .cache .turbo dist",
|
|
60
61
|
"clean:all": "pnpm clean && git clean -xdf node_modules",
|
|
61
|
-
{{#if
|
|
62
|
+
{{#if isPublishablePackage}}
|
|
62
63
|
{{#if isBundlerTsc}}
|
|
63
64
|
"build": "pnpm run clean && tsc -p tsconfig.build.json",
|
|
64
65
|
"build:watch": "pnpm run clean && tsc -p tsconfig.build.json --watch",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"@internal/eslint-config": "workspace:*",
|
|
82
83
|
"@internal/prettier-config": "workspace:*",
|
|
83
84
|
"@internal/tsconfig": "workspace:*",
|
|
84
|
-
{{#if
|
|
85
|
+
{{#if isPublishablePackage}}
|
|
85
86
|
{{#if isBundlerTsdown}}
|
|
86
87
|
{{#if hasTsdownConfig}}
|
|
87
88
|
"{{tsdownConfigPackage}}": "workspace:*",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
{{/if}}
|
|
90
91
|
{{/if}}
|
|
91
92
|
"@internal/vitest-config": "workspace:*",
|
|
92
|
-
{{#if
|
|
93
|
+
{{#if isPublishablePackage}}
|
|
93
94
|
{{#if isBundlerTsdown}}
|
|
94
95
|
{{#unless hasTsdownConfig}}
|
|
95
96
|
"{{tsdownConfigPackage}}": "^1.0.0",
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
{{/if}}
|
|
99
100
|
"@types/node": "catalog:dev",
|
|
100
101
|
{{#if isReactPackage}}
|
|
101
|
-
{{#if
|
|
102
|
+
{{#if isPublishablePackage}}
|
|
102
103
|
"@types/react": "^19.0.0",
|
|
103
104
|
"@types/react-dom": "^19.0.0",
|
|
104
105
|
{{else}}
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"@vitest/ui": "catalog:dev",
|
|
111
112
|
"eslint": "catalog:dev",
|
|
112
113
|
{{#if isReactPackage}}
|
|
113
|
-
{{#if
|
|
114
|
+
{{#if isPublishablePackage}}
|
|
114
115
|
"react": "^19.0.0",
|
|
115
116
|
"react-dom": "^19.0.0",
|
|
116
117
|
{{else}}
|
|
@@ -118,7 +119,7 @@
|
|
|
118
119
|
"react-dom": "catalog:",
|
|
119
120
|
{{/if}}
|
|
120
121
|
{{/if}}
|
|
121
|
-
{{#if
|
|
122
|
+
{{#if isPublishablePackage}}
|
|
122
123
|
{{#if isBundlerTsdown}}
|
|
123
124
|
"tsdown": "catalog:dev",
|
|
124
125
|
{{/if}}
|
|
@@ -13,7 +13,7 @@ export default defineConfig({
|
|
|
13
13
|
dts: true,
|
|
14
14
|
minify: false,
|
|
15
15
|
clean: true,
|
|
16
|
-
{{#if
|
|
16
|
+
{{#if isPublishablePackage}}
|
|
17
17
|
// Keep `process.env.NODE_ENV` intact in the output so each consumer's bundler
|
|
18
18
|
// (Next.js, Vite, etc.) can dead-code-eliminate dev-only guards in production.
|
|
19
19
|
// A `browser` platform would inline it at build time, making dev-only code run
|