@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.d.ts +190 -203
- package/index.js +12 -491
- package/lib/biome/index.js +22 -0
- package/lib/changeset/index.js +36 -0
- package/lib/gitignore/index.js +38 -0
- package/lib/package-json/index.js +94 -0
- package/lib/pnpm/index.js +33 -0
- package/lib/readme/index.js +21 -0
- package/lib/tsconfig/index.js +27 -0
- package/lib/turbo/index.js +48 -0
- package/lib/vscode/index.js +66 -0
- package/lib/workspace/index.js +81 -0
- package/package.json +34 -45
- package/tsdoc-metadata.json +11 -11
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import yaml from "js-yaml";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/pnpm/index.ts
|
|
5
|
+
const PnpmWorkspaceOptions = Schema.Struct({
|
|
6
|
+
packages: Schema.Array(Schema.String),
|
|
7
|
+
autoInstallPeers: Schema.optional(Schema.Boolean),
|
|
8
|
+
catalogMode: Schema.optional(Schema.Literal("strict", "prefer", "manual")),
|
|
9
|
+
catalog: Schema.optional(Schema.Record({
|
|
10
|
+
key: Schema.String,
|
|
11
|
+
value: Schema.String
|
|
12
|
+
}))
|
|
13
|
+
});
|
|
14
|
+
function createPnpmWorkspace(options) {
|
|
15
|
+
const opts = Schema.decodeUnknownSync(PnpmWorkspaceOptions)(options);
|
|
16
|
+
const config = { packages: opts.packages };
|
|
17
|
+
if (opts.autoInstallPeers !== void 0) config.autoInstallPeers = opts.autoInstallPeers;
|
|
18
|
+
if (opts.catalogMode) config.catalogMode = opts.catalogMode;
|
|
19
|
+
if (opts.catalog && Object.keys(opts.catalog).length > 0) config.catalog = opts.catalog;
|
|
20
|
+
return [{
|
|
21
|
+
name: "pnpm-workspace",
|
|
22
|
+
filename: "pnpm-workspace.yaml",
|
|
23
|
+
content: yaml.dump(config, {
|
|
24
|
+
indent: 2,
|
|
25
|
+
lineWidth: -1,
|
|
26
|
+
noRefs: true,
|
|
27
|
+
sortKeys: false
|
|
28
|
+
})
|
|
29
|
+
}];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { PnpmWorkspaceOptions, createPnpmWorkspace };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/readme/index.ts
|
|
4
|
+
const ReadmeOptions = Schema.Struct({
|
|
5
|
+
name: Schema.String,
|
|
6
|
+
description: Schema.optional(Schema.String)
|
|
7
|
+
});
|
|
8
|
+
function createReadme(options) {
|
|
9
|
+
const opts = Schema.decodeUnknownSync(ReadmeOptions)(options);
|
|
10
|
+
const lines = [`# ${opts.name}`];
|
|
11
|
+
if (opts.description) lines.push("", opts.description);
|
|
12
|
+
lines.push("");
|
|
13
|
+
return [{
|
|
14
|
+
name: "readme",
|
|
15
|
+
filename: "README.md",
|
|
16
|
+
content: lines.join("\n")
|
|
17
|
+
}];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ReadmeOptions, createReadme };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/tsconfig/index.ts
|
|
4
|
+
const TsConfigOptions = Schema.Struct({
|
|
5
|
+
extends: Schema.optional(Schema.Union(Schema.String, Schema.Array(Schema.String))),
|
|
6
|
+
composite: Schema.optional(Schema.Boolean),
|
|
7
|
+
include: Schema.optional(Schema.Array(Schema.String)),
|
|
8
|
+
exclude: Schema.optional(Schema.Array(Schema.String)),
|
|
9
|
+
references: Schema.optional(Schema.Array(Schema.Struct({ path: Schema.String })))
|
|
10
|
+
});
|
|
11
|
+
function createTsConfig(options) {
|
|
12
|
+
const opts = Schema.decodeUnknownSync(TsConfigOptions)(options);
|
|
13
|
+
const config = {};
|
|
14
|
+
if (opts.extends !== void 0) config.extends = typeof opts.extends === "string" ? [opts.extends] : opts.extends;
|
|
15
|
+
if (opts.composite !== void 0) config.composite = opts.composite;
|
|
16
|
+
if (opts.include) config.include = opts.include;
|
|
17
|
+
if (opts.exclude) config.exclude = opts.exclude;
|
|
18
|
+
if (opts.references) config.references = opts.references;
|
|
19
|
+
return [{
|
|
20
|
+
name: "tsconfig",
|
|
21
|
+
filename: "tsconfig.json",
|
|
22
|
+
content: JSON.stringify(config, null, " ")
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { TsConfigOptions, createTsConfig };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/turbo/index.ts
|
|
4
|
+
const TurboRootOptions = Schema.Struct({
|
|
5
|
+
tasks: Schema.Record({
|
|
6
|
+
key: Schema.String,
|
|
7
|
+
value: Schema.Unknown
|
|
8
|
+
}),
|
|
9
|
+
globalDependencies: Schema.optional(Schema.Array(Schema.String)),
|
|
10
|
+
globalEnv: Schema.optional(Schema.Array(Schema.String)),
|
|
11
|
+
globalPassThroughEnv: Schema.optional(Schema.Array(Schema.String)),
|
|
12
|
+
ui: Schema.optional(Schema.Literal("tui", "stream")),
|
|
13
|
+
concurrency: Schema.optional(Schema.Union(Schema.String, Schema.Number))
|
|
14
|
+
});
|
|
15
|
+
const TurboWorkspaceOptions = Schema.Struct({ tasks: Schema.optional(Schema.Record({
|
|
16
|
+
key: Schema.String,
|
|
17
|
+
value: Schema.Unknown
|
|
18
|
+
})) });
|
|
19
|
+
function createTurboRoot(options) {
|
|
20
|
+
const opts = Schema.decodeUnknownSync(TurboRootOptions)(options);
|
|
21
|
+
const config = {
|
|
22
|
+
$schema: "https://turborepo.com/schema.v2.json",
|
|
23
|
+
tasks: opts.tasks
|
|
24
|
+
};
|
|
25
|
+
if (opts.globalDependencies && opts.globalDependencies.length > 0) config.globalDependencies = opts.globalDependencies;
|
|
26
|
+
if (opts.globalEnv && opts.globalEnv.length > 0) config.globalEnv = opts.globalEnv;
|
|
27
|
+
if (opts.globalPassThroughEnv && opts.globalPassThroughEnv.length > 0) config.globalPassThroughEnv = opts.globalPassThroughEnv;
|
|
28
|
+
if (opts.ui) config.ui = opts.ui;
|
|
29
|
+
if (opts.concurrency !== void 0) config.concurrency = opts.concurrency;
|
|
30
|
+
return [{
|
|
31
|
+
name: "turbo-root",
|
|
32
|
+
filename: "turbo.json",
|
|
33
|
+
content: JSON.stringify(config, null, " ")
|
|
34
|
+
}];
|
|
35
|
+
}
|
|
36
|
+
function createTurboWorkspace(options) {
|
|
37
|
+
const opts = Schema.decodeUnknownSync(TurboWorkspaceOptions)(options);
|
|
38
|
+
const config = { extends: ["//"] };
|
|
39
|
+
if (opts.tasks && Object.keys(opts.tasks).length > 0) config.tasks = opts.tasks;
|
|
40
|
+
return [{
|
|
41
|
+
name: "turbo-workspace",
|
|
42
|
+
filename: "turbo.json",
|
|
43
|
+
content: JSON.stringify(config, null, " ")
|
|
44
|
+
}];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { TurboRootOptions, TurboWorkspaceOptions, createTurboRoot, createTurboWorkspace };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/vscode/index.ts
|
|
4
|
+
const Settings = Schema.Struct({
|
|
5
|
+
biome: Schema.optional(Schema.Boolean),
|
|
6
|
+
turbo: Schema.optional(Schema.Boolean),
|
|
7
|
+
vitest: Schema.optional(Schema.Boolean)
|
|
8
|
+
});
|
|
9
|
+
const VsCodeOptions = Schema.Struct({
|
|
10
|
+
settings: Schema.optional(Settings),
|
|
11
|
+
extensions: Schema.optional(Schema.Array(Schema.String))
|
|
12
|
+
});
|
|
13
|
+
function createVsCode(options) {
|
|
14
|
+
const opts = Schema.decodeUnknownSync(VsCodeOptions)(options);
|
|
15
|
+
const features = opts.settings ?? {};
|
|
16
|
+
const codeActions = { "source.fixAll.ts": "explicit" };
|
|
17
|
+
const searchExclude = {
|
|
18
|
+
"**/node_modules": true,
|
|
19
|
+
"**/dist": true,
|
|
20
|
+
"**/.rslib": true,
|
|
21
|
+
"**/*.tsbuildinfo": true
|
|
22
|
+
};
|
|
23
|
+
const filesExclude = {
|
|
24
|
+
"**/node_modules": true,
|
|
25
|
+
"**/dist": true,
|
|
26
|
+
"**/.rslib": true,
|
|
27
|
+
"**/*.tsbuildinfo": true
|
|
28
|
+
};
|
|
29
|
+
if (features.biome) {
|
|
30
|
+
codeActions["source.organizeImports.biome"] = "explicit";
|
|
31
|
+
codeActions["source.fixAll.biome"] = "explicit";
|
|
32
|
+
}
|
|
33
|
+
if (features.vitest) {
|
|
34
|
+
searchExclude["**/.vitest"] = true;
|
|
35
|
+
searchExclude["**/.coverage"] = true;
|
|
36
|
+
filesExclude["**/.vitest"] = true;
|
|
37
|
+
filesExclude["**/.coverage"] = true;
|
|
38
|
+
}
|
|
39
|
+
if (features.turbo) {
|
|
40
|
+
searchExclude["**/.turbo"] = true;
|
|
41
|
+
filesExclude["**/.turbo"] = true;
|
|
42
|
+
}
|
|
43
|
+
const settings = {
|
|
44
|
+
"editor.formatOnSave": true,
|
|
45
|
+
"eslint.enable": !features.biome,
|
|
46
|
+
"prettier.enable": !features.biome,
|
|
47
|
+
"biome.enabled": !!features.biome,
|
|
48
|
+
"biome.requireConfiguration": true,
|
|
49
|
+
"editor.codeActionsOnSave": codeActions,
|
|
50
|
+
"search.exclude": searchExclude,
|
|
51
|
+
"files.exclude": filesExclude
|
|
52
|
+
};
|
|
53
|
+
const recommendations = [...new Set(opts.extensions ?? [])].sort();
|
|
54
|
+
return [{
|
|
55
|
+
name: "vscode-settings",
|
|
56
|
+
filename: ".vscode/settings.json",
|
|
57
|
+
content: JSON.stringify(settings, null, " ")
|
|
58
|
+
}, {
|
|
59
|
+
name: "vscode-extensions",
|
|
60
|
+
filename: ".vscode/extensions.json",
|
|
61
|
+
content: JSON.stringify({ recommendations }, null, " ")
|
|
62
|
+
}];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { VsCodeOptions, createVsCode };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createBiome } from "../biome/index.js";
|
|
2
|
+
import { createChangeset } from "../changeset/index.js";
|
|
3
|
+
import { createGitignore } from "../gitignore/index.js";
|
|
4
|
+
import { createPackageJson } from "../package-json/index.js";
|
|
5
|
+
import { createPnpmWorkspace } from "../pnpm/index.js";
|
|
6
|
+
import { createReadme } from "../readme/index.js";
|
|
7
|
+
import { createTsConfig } from "../tsconfig/index.js";
|
|
8
|
+
import { createTurboRoot } from "../turbo/index.js";
|
|
9
|
+
import { createVsCode } from "../vscode/index.js";
|
|
10
|
+
import { Schema } from "effect";
|
|
11
|
+
|
|
12
|
+
//#region src/lib/workspace/index.ts
|
|
13
|
+
const Features = Schema.Struct({
|
|
14
|
+
biome: Schema.optional(Schema.Boolean),
|
|
15
|
+
vitest: Schema.optional(Schema.Boolean),
|
|
16
|
+
turbo: Schema.optional(Schema.Boolean),
|
|
17
|
+
changesets: Schema.optional(Schema.Boolean),
|
|
18
|
+
vscode: Schema.optional(Schema.Boolean)
|
|
19
|
+
});
|
|
20
|
+
const WorkspaceOptions = Schema.Struct({
|
|
21
|
+
name: Schema.String,
|
|
22
|
+
packageManager: Schema.Literal("pnpm", "npm", "bun"),
|
|
23
|
+
packageManagerVersion: Schema.String,
|
|
24
|
+
nodeVersion: Schema.String,
|
|
25
|
+
biomeVersion: Schema.optionalWith(Schema.String, { default: () => "2.3.3" }),
|
|
26
|
+
features: Schema.optional(Features)
|
|
27
|
+
});
|
|
28
|
+
function createWorkspace(options) {
|
|
29
|
+
const opts = Schema.decodeUnknownSync(WorkspaceOptions)(options);
|
|
30
|
+
const features = opts.features ?? {};
|
|
31
|
+
const entries = [];
|
|
32
|
+
entries.push(...createPackageJson({
|
|
33
|
+
name: opts.name,
|
|
34
|
+
version: "0.0.0",
|
|
35
|
+
private: true,
|
|
36
|
+
type: "module",
|
|
37
|
+
packageManager: `${opts.packageManager}@${opts.packageManagerVersion}`,
|
|
38
|
+
engines: { node: `>=${opts.nodeVersion}` }
|
|
39
|
+
}));
|
|
40
|
+
entries.push(...createTsConfig({}));
|
|
41
|
+
entries.push(...createGitignore({ sections: {
|
|
42
|
+
os: true,
|
|
43
|
+
node: true,
|
|
44
|
+
build: true,
|
|
45
|
+
env: true,
|
|
46
|
+
silk: !!features.changesets
|
|
47
|
+
} }));
|
|
48
|
+
entries.push(...createReadme({ name: opts.name }));
|
|
49
|
+
if (opts.packageManager === "pnpm") entries.push(...createPnpmWorkspace({
|
|
50
|
+
packages: ["packages/*"],
|
|
51
|
+
autoInstallPeers: true
|
|
52
|
+
}));
|
|
53
|
+
if (features.biome) entries.push(...createBiome({
|
|
54
|
+
version: opts.biomeVersion,
|
|
55
|
+
root: true
|
|
56
|
+
}));
|
|
57
|
+
if (features.turbo) entries.push(...createTurboRoot({
|
|
58
|
+
tasks: {
|
|
59
|
+
build: {
|
|
60
|
+
dependsOn: ["^build"],
|
|
61
|
+
outputs: ["dist/**"]
|
|
62
|
+
},
|
|
63
|
+
test: { dependsOn: ["build"] },
|
|
64
|
+
"types:check": {
|
|
65
|
+
cache: true,
|
|
66
|
+
outputLogs: "errors-only"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
globalPassThroughEnv: ["CI", "GITHUB_ACTIONS"]
|
|
70
|
+
}));
|
|
71
|
+
if (features.changesets) entries.push(...createChangeset({ access: "restricted" }));
|
|
72
|
+
if (features.vscode) entries.push(...createVsCode({ settings: {
|
|
73
|
+
biome: !!features.biome,
|
|
74
|
+
turbo: !!features.turbo,
|
|
75
|
+
vitest: !!features.vitest
|
|
76
|
+
} }));
|
|
77
|
+
return entries;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export { WorkspaceOptions, createWorkspace };
|
package/package.json
CHANGED
|
@@ -1,47 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"files": [
|
|
37
|
-
"!templates.api.json",
|
|
38
|
-
"!tsconfig.json",
|
|
39
|
-
"!tsdoc.json",
|
|
40
|
-
"LICENSE",
|
|
41
|
-
"README.md",
|
|
42
|
-
"index.d.ts",
|
|
43
|
-
"index.js",
|
|
44
|
-
"package.json",
|
|
45
|
-
"tsdoc-metadata.json"
|
|
46
|
-
]
|
|
2
|
+
"name": "@savvy-web/templates",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Pure TypeScript templates for Silk Suite project scaffolding",
|
|
6
|
+
"homepage": "https://github.com/savvy-web/systems/tree/main/packages/templates",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/savvy-web/systems/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/savvy-web/systems.git",
|
|
13
|
+
"directory": "packages/templates"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "C. Spencer Beggs",
|
|
18
|
+
"email": "spencer@savvyweb.systems",
|
|
19
|
+
"url": "https://savvyweb.systems"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"import": "./index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"js-yaml": "^4.1.1",
|
|
31
|
+
"sort-package-json": "^3.6.1"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"effect": ">=3.21.0"
|
|
35
|
+
}
|
|
47
36
|
}
|
package/tsdoc-metadata.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.58.7"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|