@savvy-web/templates 0.1.0 → 0.1.2

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/index.js CHANGED
@@ -1,491 +1,12 @@
1
- import { Schema } from "effect";
2
- import { sortPackageJson } from "sort-package-json";
3
- import js_yaml from "js-yaml";
4
- const BiomeOptions = Schema.Struct({
5
- version: Schema.String,
6
- extends: Schema.optional(Schema.Array(Schema.String)),
7
- root: Schema.optional(Schema.Boolean)
8
- });
9
- function createBiome(options) {
10
- const opts = Schema.decodeUnknownSync(BiomeOptions)(options);
11
- const config = {
12
- $schema: `https://biomejs.dev/schemas/${opts.version}/schema.json`
13
- };
14
- if (opts.extends && opts.extends.length > 0) config.extends = opts.extends;
15
- if (void 0 !== opts.root) config.root = opts.root;
16
- const content = JSON.stringify(config, null, "\t");
17
- return [
18
- {
19
- name: "biome",
20
- filename: "biome.jsonc",
21
- content
22
- }
23
- ];
24
- }
25
- const RepoPattern = Schema.String.pipe(Schema.pattern(/^[^/\s]+\/[^/\s]+$/));
26
- const ChangesetOptions = Schema.Struct({
27
- access: Schema.optionalWith(Schema.Literal("public", "restricted"), {
28
- default: ()=>"restricted"
29
- }),
30
- baseBranch: Schema.optionalWith(Schema.String, {
31
- default: ()=>"main"
32
- }),
33
- changelog: Schema.optionalWith(Schema.String, {
34
- default: ()=>"@savvy-web/changesets/changelog"
35
- }),
36
- repo: Schema.optional(RepoPattern)
37
- });
38
- function createChangeset(options) {
39
- const opts = Schema.decodeUnknownSync(ChangesetOptions)(options);
40
- const config = {
41
- $schema: "https://unpkg.com/@changesets/config@3.1.1/schema.json",
42
- changelog: opts.repo ? [
43
- opts.changelog,
44
- {
45
- repo: opts.repo
46
- }
47
- ] : opts.changelog,
48
- commit: false,
49
- fixed: [],
50
- linked: [],
51
- access: opts.access,
52
- baseBranch: opts.baseBranch,
53
- updateInternalDependencies: "patch",
54
- privatePackages: {
55
- version: true,
56
- tag: false
57
- },
58
- ignore: []
59
- };
60
- const content = JSON.stringify(config, null, "\t");
61
- return [
62
- {
63
- name: "changeset",
64
- filename: ".changeset/config.json",
65
- content
66
- }
67
- ];
68
- }
69
- const GitignoreOptions = Schema.Struct({
70
- sections: Schema.optional(Schema.Struct({
71
- node: Schema.optional(Schema.Boolean),
72
- build: Schema.optional(Schema.Boolean),
73
- env: Schema.optional(Schema.Boolean),
74
- os: Schema.optional(Schema.Boolean),
75
- silk: Schema.optional(Schema.Boolean)
76
- })),
77
- additional: Schema.optional(Schema.Array(Schema.String))
78
- });
79
- function createGitignore(options) {
80
- const opts = Schema.decodeUnknownSync(GitignoreOptions)(options);
81
- const sections = {
82
- node: opts.sections?.node ?? true,
83
- build: opts.sections?.build ?? true,
84
- env: opts.sections?.env ?? true,
85
- os: opts.sections?.os ?? true,
86
- silk: opts.sections?.silk ?? true
87
- };
88
- const lines = [];
89
- if (sections.os) lines.push("# OS files", "**/.DS_Store", "");
90
- if (sections.node) lines.push("# Node.js", "**/node_modules", "**/*.tsbuildinfo*", "");
91
- if (sections.build) lines.push("# Build artifacts", "**/dist", "**/.rslib", "**/.turbo", "**/*.api.json", "", "# Test artifacts", "**/.coverage", "**/.vitest", "");
92
- if (sections.silk) lines.push("# Release artifacts", "pnpm-publish-summary.json", "pnpm-release.json", ".changeset/status.json", "", "# Private keys", "**/*.asc", "", "# AI agent settings", ".mcp.json", "");
93
- if (sections.env) lines.push("# Environment files", "**/.env", "**/.env.*", "");
94
- if (opts.additional && opts.additional.length > 0) lines.push("# Additional", ...opts.additional, "");
95
- const content = lines.join("\n");
96
- return [
97
- {
98
- name: "gitignore",
99
- filename: ".gitignore",
100
- content
101
- }
102
- ];
103
- }
104
- const Author = Schema.Struct({
105
- name: Schema.String,
106
- email: Schema.optional(Schema.String),
107
- url: Schema.optional(Schema.String)
108
- });
109
- const Bugs = Schema.Struct({
110
- url: Schema.String
111
- });
112
- const Repository = Schema.Struct({
113
- type: Schema.String,
114
- url: Schema.String,
115
- directory: Schema.optional(Schema.String)
116
- });
117
- const PublishConfig = Schema.Struct({
118
- access: Schema.optional(Schema.String),
119
- directory: Schema.optional(Schema.String),
120
- linkDirectory: Schema.optional(Schema.Boolean),
121
- targets: Schema.optional(Schema.Unknown)
122
- });
123
- const PackageJsonOptions = Schema.Struct({
124
- name: Schema.String,
125
- version: Schema.optionalWith(Schema.String, {
126
- default: ()=>"0.0.0"
127
- }),
128
- private: Schema.optional(Schema.Boolean),
129
- description: Schema.optional(Schema.String),
130
- homepage: Schema.optional(Schema.String),
131
- bugs: Schema.optional(Bugs),
132
- repository: Schema.optional(Repository),
133
- license: Schema.optional(Schema.String),
134
- author: Schema.optional(Author),
135
- sideEffects: Schema.optional(Schema.Boolean),
136
- type: Schema.optional(Schema.Literal("module", "commonjs")),
137
- exports: Schema.optional(Schema.Unknown),
138
- scripts: Schema.optional(Schema.Record({
139
- key: Schema.String,
140
- value: Schema.String
141
- })),
142
- dependencies: Schema.optional(Schema.Record({
143
- key: Schema.String,
144
- value: Schema.String
145
- })),
146
- devDependencies: Schema.optional(Schema.Record({
147
- key: Schema.String,
148
- value: Schema.String
149
- })),
150
- peerDependencies: Schema.optional(Schema.Record({
151
- key: Schema.String,
152
- value: Schema.String
153
- })),
154
- engines: Schema.optional(Schema.Struct({
155
- node: Schema.optional(Schema.String),
156
- pnpm: Schema.optional(Schema.String)
157
- })),
158
- packageManager: Schema.optional(Schema.String),
159
- devEngines: Schema.optional(Schema.Unknown),
160
- publishConfig: Schema.optional(PublishConfig),
161
- keywords: Schema.optional(Schema.Array(Schema.String))
162
- });
163
- function createPackageJson(options) {
164
- const opts = Schema.decodeUnknownSync(PackageJsonOptions)(options);
165
- const pkg = {
166
- name: opts.name,
167
- version: opts.version
168
- };
169
- if (void 0 !== opts.private) pkg.private = opts.private;
170
- if (opts.description) pkg.description = opts.description;
171
- if (opts.homepage) pkg.homepage = opts.homepage;
172
- if (opts.bugs) pkg.bugs = opts.bugs;
173
- if (opts.repository) pkg.repository = opts.repository;
174
- if (opts.license) pkg.license = opts.license;
175
- if (opts.author) pkg.author = opts.author;
176
- if (void 0 !== opts.sideEffects) pkg.sideEffects = opts.sideEffects;
177
- if (opts.type) pkg.type = opts.type;
178
- if (opts.exports) pkg.exports = opts.exports;
179
- if (opts.scripts && Object.keys(opts.scripts).length > 0) pkg.scripts = opts.scripts;
180
- if (opts.dependencies && Object.keys(opts.dependencies).length > 0) pkg.dependencies = opts.dependencies;
181
- if (opts.devDependencies && Object.keys(opts.devDependencies).length > 0) pkg.devDependencies = opts.devDependencies;
182
- if (opts.peerDependencies && Object.keys(opts.peerDependencies).length > 0) pkg.peerDependencies = opts.peerDependencies;
183
- if (opts.engines) pkg.engines = opts.engines;
184
- if (opts.packageManager) pkg.packageManager = opts.packageManager;
185
- if (opts.devEngines) pkg.devEngines = opts.devEngines;
186
- if (opts.publishConfig) pkg.publishConfig = opts.publishConfig;
187
- if (opts.keywords && opts.keywords.length > 0) pkg.keywords = opts.keywords;
188
- const sorted = sortPackageJson(pkg);
189
- const content = JSON.stringify(sorted, null, "\t");
190
- return [
191
- {
192
- name: "package-json",
193
- filename: "package.json",
194
- content
195
- }
196
- ];
197
- }
198
- const PnpmWorkspaceOptions = Schema.Struct({
199
- packages: Schema.Array(Schema.String),
200
- autoInstallPeers: Schema.optional(Schema.Boolean),
201
- catalogMode: Schema.optional(Schema.Literal("strict", "prefer", "manual")),
202
- catalog: Schema.optional(Schema.Record({
203
- key: Schema.String,
204
- value: Schema.String
205
- }))
206
- });
207
- function createPnpmWorkspace(options) {
208
- const opts = Schema.decodeUnknownSync(PnpmWorkspaceOptions)(options);
209
- const config = {
210
- packages: opts.packages
211
- };
212
- if (void 0 !== opts.autoInstallPeers) config.autoInstallPeers = opts.autoInstallPeers;
213
- if (opts.catalogMode) config.catalogMode = opts.catalogMode;
214
- if (opts.catalog && Object.keys(opts.catalog).length > 0) config.catalog = opts.catalog;
215
- const content = js_yaml.dump(config, {
216
- indent: 2,
217
- lineWidth: -1,
218
- noRefs: true,
219
- sortKeys: false
220
- });
221
- return [
222
- {
223
- name: "pnpm-workspace",
224
- filename: "pnpm-workspace.yaml",
225
- content
226
- }
227
- ];
228
- }
229
- const ReadmeOptions = Schema.Struct({
230
- name: Schema.String,
231
- description: Schema.optional(Schema.String)
232
- });
233
- function createReadme(options) {
234
- const opts = Schema.decodeUnknownSync(ReadmeOptions)(options);
235
- const lines = [
236
- `# ${opts.name}`
237
- ];
238
- if (opts.description) lines.push("", opts.description);
239
- lines.push("");
240
- const content = lines.join("\n");
241
- return [
242
- {
243
- name: "readme",
244
- filename: "README.md",
245
- content
246
- }
247
- ];
248
- }
249
- const TsConfigOptions = Schema.Struct({
250
- extends: Schema.optional(Schema.Union(Schema.String, Schema.Array(Schema.String))),
251
- composite: Schema.optional(Schema.Boolean),
252
- include: Schema.optional(Schema.Array(Schema.String)),
253
- exclude: Schema.optional(Schema.Array(Schema.String)),
254
- references: Schema.optional(Schema.Array(Schema.Struct({
255
- path: Schema.String
256
- })))
257
- });
258
- function createTsConfig(options) {
259
- const opts = Schema.decodeUnknownSync(TsConfigOptions)(options);
260
- const config = {};
261
- if (void 0 !== opts.extends) config.extends = "string" == typeof opts.extends ? [
262
- opts.extends
263
- ] : opts.extends;
264
- if (void 0 !== opts.composite) config.composite = opts.composite;
265
- if (opts.include) config.include = opts.include;
266
- if (opts.exclude) config.exclude = opts.exclude;
267
- if (opts.references) config.references = opts.references;
268
- const content = JSON.stringify(config, null, "\t");
269
- return [
270
- {
271
- name: "tsconfig",
272
- filename: "tsconfig.json",
273
- content
274
- }
275
- ];
276
- }
277
- const TurboRootOptions = Schema.Struct({
278
- tasks: Schema.Record({
279
- key: Schema.String,
280
- value: Schema.Unknown
281
- }),
282
- globalDependencies: Schema.optional(Schema.Array(Schema.String)),
283
- globalEnv: Schema.optional(Schema.Array(Schema.String)),
284
- globalPassThroughEnv: Schema.optional(Schema.Array(Schema.String)),
285
- ui: Schema.optional(Schema.Literal("tui", "stream")),
286
- concurrency: Schema.optional(Schema.Union(Schema.String, Schema.Number))
287
- });
288
- const TurboWorkspaceOptions = Schema.Struct({
289
- tasks: Schema.optional(Schema.Record({
290
- key: Schema.String,
291
- value: Schema.Unknown
292
- }))
293
- });
294
- function createTurboRoot(options) {
295
- const opts = Schema.decodeUnknownSync(TurboRootOptions)(options);
296
- const config = {
297
- $schema: "https://turborepo.com/schema.v2.json",
298
- tasks: opts.tasks
299
- };
300
- if (opts.globalDependencies && opts.globalDependencies.length > 0) config.globalDependencies = opts.globalDependencies;
301
- if (opts.globalEnv && opts.globalEnv.length > 0) config.globalEnv = opts.globalEnv;
302
- if (opts.globalPassThroughEnv && opts.globalPassThroughEnv.length > 0) config.globalPassThroughEnv = opts.globalPassThroughEnv;
303
- if (opts.ui) config.ui = opts.ui;
304
- if (void 0 !== opts.concurrency) config.concurrency = opts.concurrency;
305
- const content = JSON.stringify(config, null, "\t");
306
- return [
307
- {
308
- name: "turbo-root",
309
- filename: "turbo.json",
310
- content
311
- }
312
- ];
313
- }
314
- function createTurboWorkspace(options) {
315
- const opts = Schema.decodeUnknownSync(TurboWorkspaceOptions)(options);
316
- const config = {
317
- extends: [
318
- "//"
319
- ]
320
- };
321
- if (opts.tasks && Object.keys(opts.tasks).length > 0) config.tasks = opts.tasks;
322
- const content = JSON.stringify(config, null, "\t");
323
- return [
324
- {
325
- name: "turbo-workspace",
326
- filename: "turbo.json",
327
- content
328
- }
329
- ];
330
- }
331
- const Settings = Schema.Struct({
332
- biome: Schema.optional(Schema.Boolean),
333
- turbo: Schema.optional(Schema.Boolean),
334
- vitest: Schema.optional(Schema.Boolean)
335
- });
336
- const VsCodeOptions = Schema.Struct({
337
- settings: Schema.optional(Settings),
338
- extensions: Schema.optional(Schema.Array(Schema.String))
339
- });
340
- function createVsCode(options) {
341
- const opts = Schema.decodeUnknownSync(VsCodeOptions)(options);
342
- const features = opts.settings ?? {};
343
- const codeActions = {
344
- "source.fixAll.ts": "explicit"
345
- };
346
- const searchExclude = {
347
- "**/node_modules": true,
348
- "**/dist": true,
349
- "**/.rslib": true,
350
- "**/*.tsbuildinfo": true
351
- };
352
- const filesExclude = {
353
- "**/node_modules": true,
354
- "**/dist": true,
355
- "**/.rslib": true,
356
- "**/*.tsbuildinfo": true
357
- };
358
- if (features.biome) {
359
- codeActions["source.organizeImports.biome"] = "explicit";
360
- codeActions["source.fixAll.biome"] = "explicit";
361
- }
362
- if (features.vitest) {
363
- searchExclude["**/.vitest"] = true;
364
- searchExclude["**/.coverage"] = true;
365
- filesExclude["**/.vitest"] = true;
366
- filesExclude["**/.coverage"] = true;
367
- }
368
- if (features.turbo) {
369
- searchExclude["**/.turbo"] = true;
370
- filesExclude["**/.turbo"] = true;
371
- }
372
- const settings = {
373
- "editor.formatOnSave": true,
374
- "eslint.enable": !features.biome,
375
- "prettier.enable": !features.biome,
376
- "biome.enabled": !!features.biome,
377
- "biome.requireConfiguration": true,
378
- "editor.codeActionsOnSave": codeActions,
379
- "search.exclude": searchExclude,
380
- "files.exclude": filesExclude
381
- };
382
- const recommendations = [
383
- ...new Set(opts.extensions ?? [])
384
- ].sort();
385
- return [
386
- {
387
- name: "vscode-settings",
388
- filename: ".vscode/settings.json",
389
- content: JSON.stringify(settings, null, "\t")
390
- },
391
- {
392
- name: "vscode-extensions",
393
- filename: ".vscode/extensions.json",
394
- content: JSON.stringify({
395
- recommendations
396
- }, null, "\t")
397
- }
398
- ];
399
- }
400
- const Features = Schema.Struct({
401
- biome: Schema.optional(Schema.Boolean),
402
- vitest: Schema.optional(Schema.Boolean),
403
- turbo: Schema.optional(Schema.Boolean),
404
- changesets: Schema.optional(Schema.Boolean),
405
- vscode: Schema.optional(Schema.Boolean)
406
- });
407
- const WorkspaceOptions = Schema.Struct({
408
- name: Schema.String,
409
- packageManager: Schema.Literal("pnpm", "npm", "bun"),
410
- packageManagerVersion: Schema.String,
411
- nodeVersion: Schema.String,
412
- biomeVersion: Schema.optionalWith(Schema.String, {
413
- default: ()=>"2.3.3"
414
- }),
415
- features: Schema.optional(Features)
416
- });
417
- function createWorkspace(options) {
418
- const opts = Schema.decodeUnknownSync(WorkspaceOptions)(options);
419
- const features = opts.features ?? {};
420
- const entries = [];
421
- entries.push(...createPackageJson({
422
- name: opts.name,
423
- version: "0.0.0",
424
- private: true,
425
- type: "module",
426
- packageManager: `${opts.packageManager}@${opts.packageManagerVersion}`,
427
- engines: {
428
- node: `>=${opts.nodeVersion}`
429
- }
430
- }));
431
- entries.push(...createTsConfig({}));
432
- entries.push(...createGitignore({
433
- sections: {
434
- os: true,
435
- node: true,
436
- build: true,
437
- env: true,
438
- silk: !!features.changesets
439
- }
440
- }));
441
- entries.push(...createReadme({
442
- name: opts.name
443
- }));
444
- if ("pnpm" === opts.packageManager) entries.push(...createPnpmWorkspace({
445
- packages: [
446
- "packages/*"
447
- ],
448
- autoInstallPeers: true
449
- }));
450
- if (features.biome) entries.push(...createBiome({
451
- version: opts.biomeVersion,
452
- root: true
453
- }));
454
- if (features.turbo) entries.push(...createTurboRoot({
455
- tasks: {
456
- build: {
457
- dependsOn: [
458
- "^build"
459
- ],
460
- outputs: [
461
- "dist/**"
462
- ]
463
- },
464
- test: {
465
- dependsOn: [
466
- "build"
467
- ]
468
- },
469
- "types:check": {
470
- cache: true,
471
- outputLogs: "errors-only"
472
- }
473
- },
474
- globalPassThroughEnv: [
475
- "CI",
476
- "GITHUB_ACTIONS"
477
- ]
478
- }));
479
- if (features.changesets) entries.push(...createChangeset({
480
- access: "restricted"
481
- }));
482
- if (features.vscode) entries.push(...createVsCode({
483
- settings: {
484
- biome: !!features.biome,
485
- turbo: !!features.turbo,
486
- vitest: !!features.vitest
487
- }
488
- }));
489
- return entries;
490
- }
491
- export { BiomeOptions, ChangesetOptions, GitignoreOptions, PackageJsonOptions, PnpmWorkspaceOptions, ReadmeOptions, TsConfigOptions, TurboRootOptions, TurboWorkspaceOptions, VsCodeOptions, WorkspaceOptions, createBiome, createChangeset, createGitignore, createPackageJson, createPnpmWorkspace, createReadme, createTsConfig, createTurboRoot, createTurboWorkspace, createVsCode, createWorkspace };
1
+ import { BiomeOptions, createBiome } from "./lib/biome/index.js";
2
+ import { ChangesetOptions, createChangeset } from "./lib/changeset/index.js";
3
+ import { GitignoreOptions, createGitignore } from "./lib/gitignore/index.js";
4
+ import { PackageJsonOptions, createPackageJson } from "./lib/package-json/index.js";
5
+ import { PnpmWorkspaceOptions, createPnpmWorkspace } from "./lib/pnpm/index.js";
6
+ import { ReadmeOptions, createReadme } from "./lib/readme/index.js";
7
+ import { TsConfigOptions, createTsConfig } from "./lib/tsconfig/index.js";
8
+ import { TurboRootOptions, TurboWorkspaceOptions, createTurboRoot, createTurboWorkspace } from "./lib/turbo/index.js";
9
+ import { VsCodeOptions, createVsCode } from "./lib/vscode/index.js";
10
+ import { WorkspaceOptions, createWorkspace } from "./lib/workspace/index.js";
11
+
12
+ export { BiomeOptions, ChangesetOptions, GitignoreOptions, PackageJsonOptions, PnpmWorkspaceOptions, ReadmeOptions, TsConfigOptions, TurboRootOptions, TurboWorkspaceOptions, VsCodeOptions, WorkspaceOptions, createBiome, createChangeset, createGitignore, createPackageJson, createPnpmWorkspace, createReadme, createTsConfig, createTurboRoot, createTurboWorkspace, createVsCode, createWorkspace };
@@ -0,0 +1,22 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/lib/biome/index.ts
4
+ const BiomeOptions = Schema.Struct({
5
+ version: Schema.String,
6
+ extends: Schema.optional(Schema.Array(Schema.String)),
7
+ root: Schema.optional(Schema.Boolean)
8
+ });
9
+ function createBiome(options) {
10
+ const opts = Schema.decodeUnknownSync(BiomeOptions)(options);
11
+ const config = { $schema: `https://biomejs.dev/schemas/${opts.version}/schema.json` };
12
+ if (opts.extends && opts.extends.length > 0) config.extends = opts.extends;
13
+ if (opts.root !== void 0) config.root = opts.root;
14
+ return [{
15
+ name: "biome",
16
+ filename: "biome.jsonc",
17
+ content: JSON.stringify(config, null, " ")
18
+ }];
19
+ }
20
+
21
+ //#endregion
22
+ export { BiomeOptions, createBiome };
@@ -0,0 +1,36 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/lib/changeset/index.ts
4
+ const RepoPattern = Schema.String.pipe(Schema.pattern(/^[^/\s]+\/[^/\s]+$/));
5
+ const ChangesetOptions = Schema.Struct({
6
+ access: Schema.optionalWith(Schema.Literal("public", "restricted"), { default: () => "restricted" }),
7
+ baseBranch: Schema.optionalWith(Schema.String, { default: () => "main" }),
8
+ changelog: Schema.optionalWith(Schema.String, { default: () => "@savvy-web/changesets/changelog" }),
9
+ repo: Schema.optional(RepoPattern)
10
+ });
11
+ function createChangeset(options) {
12
+ const opts = Schema.decodeUnknownSync(ChangesetOptions)(options);
13
+ const config = {
14
+ $schema: "https://unpkg.com/@changesets/config@3.1.1/schema.json",
15
+ changelog: opts.repo ? [opts.changelog, { repo: opts.repo }] : opts.changelog,
16
+ commit: false,
17
+ fixed: [],
18
+ linked: [],
19
+ access: opts.access,
20
+ baseBranch: opts.baseBranch,
21
+ updateInternalDependencies: "patch",
22
+ privatePackages: {
23
+ version: true,
24
+ tag: false
25
+ },
26
+ ignore: []
27
+ };
28
+ return [{
29
+ name: "changeset",
30
+ filename: ".changeset/config.json",
31
+ content: JSON.stringify(config, null, " ")
32
+ }];
33
+ }
34
+
35
+ //#endregion
36
+ export { ChangesetOptions, createChangeset };
@@ -0,0 +1,38 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/lib/gitignore/index.ts
4
+ const GitignoreOptions = Schema.Struct({
5
+ sections: Schema.optional(Schema.Struct({
6
+ node: Schema.optional(Schema.Boolean),
7
+ build: Schema.optional(Schema.Boolean),
8
+ env: Schema.optional(Schema.Boolean),
9
+ os: Schema.optional(Schema.Boolean),
10
+ silk: Schema.optional(Schema.Boolean)
11
+ })),
12
+ additional: Schema.optional(Schema.Array(Schema.String))
13
+ });
14
+ function createGitignore(options) {
15
+ const opts = Schema.decodeUnknownSync(GitignoreOptions)(options);
16
+ const sections = {
17
+ node: opts.sections?.node ?? true,
18
+ build: opts.sections?.build ?? true,
19
+ env: opts.sections?.env ?? true,
20
+ os: opts.sections?.os ?? true,
21
+ silk: opts.sections?.silk ?? true
22
+ };
23
+ const lines = [];
24
+ if (sections.os) lines.push("# OS files", "**/.DS_Store", "");
25
+ if (sections.node) lines.push("# Node.js", "**/node_modules", "**/*.tsbuildinfo*", "");
26
+ if (sections.build) lines.push("# Build artifacts", "**/dist", "**/.rslib", "**/.turbo", "**/*.api.json", "", "# Test artifacts", "**/.coverage", "**/.vitest", "");
27
+ if (sections.silk) lines.push("# Release artifacts", "pnpm-publish-summary.json", "pnpm-release.json", ".changeset/status.json", "", "# Private keys", "**/*.asc", "", "# AI agent settings", ".mcp.json", "");
28
+ if (sections.env) lines.push("# Environment files", "**/.env", "**/.env.*", "");
29
+ if (opts.additional && opts.additional.length > 0) lines.push("# Additional", ...opts.additional, "");
30
+ return [{
31
+ name: "gitignore",
32
+ filename: ".gitignore",
33
+ content: lines.join("\n")
34
+ }];
35
+ }
36
+
37
+ //#endregion
38
+ export { GitignoreOptions, createGitignore };
@@ -0,0 +1,94 @@
1
+ import { Schema } from "effect";
2
+ import { sortPackageJson } from "sort-package-json";
3
+
4
+ //#region src/lib/package-json/index.ts
5
+ const Author = Schema.Struct({
6
+ name: Schema.String,
7
+ email: Schema.optional(Schema.String),
8
+ url: Schema.optional(Schema.String)
9
+ });
10
+ const Bugs = Schema.Struct({ url: Schema.String });
11
+ const Repository = Schema.Struct({
12
+ type: Schema.String,
13
+ url: Schema.String,
14
+ directory: Schema.optional(Schema.String)
15
+ });
16
+ const PublishConfig = Schema.Struct({
17
+ access: Schema.optional(Schema.String),
18
+ directory: Schema.optional(Schema.String),
19
+ linkDirectory: Schema.optional(Schema.Boolean),
20
+ targets: Schema.optional(Schema.Unknown)
21
+ });
22
+ const PackageJsonOptions = Schema.Struct({
23
+ name: Schema.String,
24
+ version: Schema.optionalWith(Schema.String, { default: () => "0.0.0" }),
25
+ private: Schema.optional(Schema.Boolean),
26
+ description: Schema.optional(Schema.String),
27
+ homepage: Schema.optional(Schema.String),
28
+ bugs: Schema.optional(Bugs),
29
+ repository: Schema.optional(Repository),
30
+ license: Schema.optional(Schema.String),
31
+ author: Schema.optional(Author),
32
+ sideEffects: Schema.optional(Schema.Boolean),
33
+ type: Schema.optional(Schema.Literal("module", "commonjs")),
34
+ exports: Schema.optional(Schema.Unknown),
35
+ scripts: Schema.optional(Schema.Record({
36
+ key: Schema.String,
37
+ value: Schema.String
38
+ })),
39
+ dependencies: Schema.optional(Schema.Record({
40
+ key: Schema.String,
41
+ value: Schema.String
42
+ })),
43
+ devDependencies: Schema.optional(Schema.Record({
44
+ key: Schema.String,
45
+ value: Schema.String
46
+ })),
47
+ peerDependencies: Schema.optional(Schema.Record({
48
+ key: Schema.String,
49
+ value: Schema.String
50
+ })),
51
+ engines: Schema.optional(Schema.Struct({
52
+ node: Schema.optional(Schema.String),
53
+ pnpm: Schema.optional(Schema.String)
54
+ })),
55
+ packageManager: Schema.optional(Schema.String),
56
+ devEngines: Schema.optional(Schema.Unknown),
57
+ publishConfig: Schema.optional(PublishConfig),
58
+ keywords: Schema.optional(Schema.Array(Schema.String))
59
+ });
60
+ function createPackageJson(options) {
61
+ const opts = Schema.decodeUnknownSync(PackageJsonOptions)(options);
62
+ const pkg = {
63
+ name: opts.name,
64
+ version: opts.version
65
+ };
66
+ if (opts.private !== void 0) pkg.private = opts.private;
67
+ if (opts.description) pkg.description = opts.description;
68
+ if (opts.homepage) pkg.homepage = opts.homepage;
69
+ if (opts.bugs) pkg.bugs = opts.bugs;
70
+ if (opts.repository) pkg.repository = opts.repository;
71
+ if (opts.license) pkg.license = opts.license;
72
+ if (opts.author) pkg.author = opts.author;
73
+ if (opts.sideEffects !== void 0) pkg.sideEffects = opts.sideEffects;
74
+ if (opts.type) pkg.type = opts.type;
75
+ if (opts.exports) pkg.exports = opts.exports;
76
+ if (opts.scripts && Object.keys(opts.scripts).length > 0) pkg.scripts = opts.scripts;
77
+ if (opts.dependencies && Object.keys(opts.dependencies).length > 0) pkg.dependencies = opts.dependencies;
78
+ if (opts.devDependencies && Object.keys(opts.devDependencies).length > 0) pkg.devDependencies = opts.devDependencies;
79
+ if (opts.peerDependencies && Object.keys(opts.peerDependencies).length > 0) pkg.peerDependencies = opts.peerDependencies;
80
+ if (opts.engines) pkg.engines = opts.engines;
81
+ if (opts.packageManager) pkg.packageManager = opts.packageManager;
82
+ if (opts.devEngines) pkg.devEngines = opts.devEngines;
83
+ if (opts.publishConfig) pkg.publishConfig = opts.publishConfig;
84
+ if (opts.keywords && opts.keywords.length > 0) pkg.keywords = opts.keywords;
85
+ const sorted = sortPackageJson(pkg);
86
+ return [{
87
+ name: "package-json",
88
+ filename: "package.json",
89
+ content: JSON.stringify(sorted, null, " ")
90
+ }];
91
+ }
92
+
93
+ //#endregion
94
+ export { PackageJsonOptions, createPackageJson };