@shrkcrft/presets 0.1.0-alpha.2 → 0.1.0-alpha.4
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.
|
@@ -7,9 +7,9 @@ export declare const COMMON_TEMPLATE_SERVICE = "defineTemplate({\n id: 'types
|
|
|
7
7
|
export declare const COMMON_TEMPLATE_UTILITY = "defineTemplate({\n id: 'typescript.utility',\n name: 'typescript-utility',\n description: 'A pure utility module (one exported function per file).',\n tags: ['typescript', 'utility'],\n scope: ['app'],\n appliesWhen: ['generate-utility'],\n variables: [\n {\n name: 'functionName',\n required: true,\n description: 'camelCase function name (e.g. formatDate).',\n pattern: /^[a-z][A-Za-z0-9]+$/,\n },\n ],\n targetPath: (v) => `src/utils/${v.functionName}.ts`,\n content: (v) => `export function ${v.functionName}(): void {\\n // TODO\\n}\\n`,\n })";
|
|
8
8
|
export declare const COMMON_TEMPLATE_TEST = "defineTemplate({\n id: 'typescript.unit-test',\n name: 'typescript-unit-test',\n description: 'A bun:test unit-test skeleton for an existing module.',\n tags: ['typescript', 'testing'],\n scope: ['app'],\n appliesWhen: ['generate-test'],\n variables: [\n {\n name: 'subject',\n required: true,\n description: 'Subject name (used in describe + filename).',\n pattern: /^[A-Za-z][A-Za-z0-9]+$/,\n },\n ],\n targetPath: (v) => `tests/${v.subject}.spec.ts`,\n content: (v) =>\n `import { describe, expect, test } from 'bun:test';\\n\\ndescribe('${v.subject}', () => {\\n test('placeholder', () => {\\n expect(true).toBe(true);\\n });\\n});\\n`,\n })";
|
|
9
9
|
export declare const TEMPLATE_HELPERS = "function kebab(s: string): string {\n return s\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[^A-Za-z0-9]+/g, '-')\n .toLowerCase();\n}";
|
|
10
|
-
export declare const COMMON_PATH_SERVICES = "defineKnowledgeEntry({\n id: 'paths.services',\n title: 'Services live in src/services/',\n type: KnowledgeType.Path,\n priority: KnowledgePriority.High,\n tags: ['paths', 'services'],\n scope: ['app'],\n appliesWhen: ['generate-service'],\n content: 'Service classes live in src/services/. One service per file.',\n })";
|
|
11
|
-
export declare const COMMON_PATH_UTILS = "defineKnowledgeEntry({\n id: 'paths.utils',\n title: 'Utilities live in src/utils/',\n type: KnowledgeType.Path,\n priority: KnowledgePriority.Medium,\n tags: ['paths', 'utils'],\n appliesWhen: ['generate-utility'],\n content: 'Pure helpers live in src/utils/. One function per file.',\n })";
|
|
12
|
-
export declare const COMMON_PATH_TESTS = "defineKnowledgeEntry({\n id: 'paths.tests',\n title: 'Tests live in tests/',\n type: KnowledgeType.Path,\n priority: KnowledgePriority.Medium,\n tags: ['paths', 'tests'],\n appliesWhen: ['generate-test'],\n content: 'Unit tests live under tests/, mirroring src/. Use *.spec.ts.',\n })";
|
|
10
|
+
export declare const COMMON_PATH_SERVICES = "defineKnowledgeEntry({\n id: 'paths.services',\n title: 'Services live in src/services/',\n type: KnowledgeType.Path,\n priority: KnowledgePriority.High,\n tags: ['paths', 'services'],\n scope: ['app'],\n appliesWhen: ['generate-service'],\n content: 'Service classes live in src/services/. One service per file.',\n metadata: { path: 'src/services' },\n })";
|
|
11
|
+
export declare const COMMON_PATH_UTILS = "defineKnowledgeEntry({\n id: 'paths.utils',\n title: 'Utilities live in src/utils/',\n type: KnowledgeType.Path,\n priority: KnowledgePriority.Medium,\n tags: ['paths', 'utils'],\n appliesWhen: ['generate-utility'],\n content: 'Pure helpers live in src/utils/. One function per file.',\n metadata: { path: 'src/utils' },\n })";
|
|
12
|
+
export declare const COMMON_PATH_TESTS = "defineKnowledgeEntry({\n id: 'paths.tests',\n title: 'Tests live in tests/',\n type: KnowledgeType.Path,\n priority: KnowledgePriority.Medium,\n tags: ['paths', 'tests'],\n appliesWhen: ['generate-test'],\n content: 'Unit tests live under tests/, mirroring src/. Use *.spec.ts.',\n metadata: { path: 'tests' },\n })";
|
|
13
13
|
export declare const COMMON_RULE_INTERFACE_PREFIX = "defineKnowledgeEntry({\n id: 'typescript.interfaces.i-prefix',\n title: 'Prefix interfaces with I',\n type: KnowledgeType.Rule,\n priority: KnowledgePriority.High,\n tags: ['typescript', 'naming'],\n appliesWhen: ['generate-code', 'refactor'],\n content: 'Interfaces use an I-prefix (IUser, IConfig). Enums are preferred over unions for closed sets.',\n })";
|
|
14
14
|
export declare const COMMON_RULE_ONE_EXPORT = "defineKnowledgeEntry({\n id: 'typescript.files.one-export',\n title: 'One exported construct per file',\n type: KnowledgeType.Rule,\n priority: KnowledgePriority.High,\n tags: ['typescript', 'structure'],\n appliesWhen: ['generate-code'],\n content: 'Each TypeScript file exports exactly one top-level construct. Helpers live in their own file.',\n })";
|
|
15
15
|
export declare const COMMON_RULE_NO_LOGIC_CONSTRUCTORS = "defineKnowledgeEntry({\n id: 'typescript.constructors.no-logic',\n title: 'No business logic in constructors',\n type: KnowledgeType.Rule,\n priority: KnowledgePriority.High,\n tags: ['typescript'],\n appliesWhen: ['generate-code'],\n content: 'Constructors wire dependencies only. Initialization belongs in init().',\n })";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-snippets.d.ts","sourceRoot":"","sources":["../../src/builtin/shared-snippets.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,m9BAuB7B,CAAC;AAEN,eAAO,MAAM,kBAAkB,45BAoB1B,CAAC;AAEN,eAAO,MAAM,2BAA2B,s9CA6CnC,CAAC;AAEN,eAAO,MAAM,4BAA4B,s5BA6BpC,CAAC;AAEN,eAAO,MAAM,yBAAyB,yVAajC,CAAC;AAEN,eAAO,MAAM,uBAAuB,mtBAkB/B,CAAC;AAEN,eAAO,MAAM,uBAAuB,8mBAiB/B,CAAC;AAEN,eAAO,MAAM,oBAAoB,ytBAkB5B,CAAC;AAKN,eAAO,MAAM,gBAAgB,8JAK3B,CAAC;AAEH,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"shared-snippets.d.ts","sourceRoot":"","sources":["../../src/builtin/shared-snippets.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,m9BAuB7B,CAAC;AAEN,eAAO,MAAM,kBAAkB,45BAoB1B,CAAC;AAEN,eAAO,MAAM,2BAA2B,s9CA6CnC,CAAC;AAEN,eAAO,MAAM,4BAA4B,s5BA6BpC,CAAC;AAEN,eAAO,MAAM,yBAAyB,yVAajC,CAAC;AAEN,eAAO,MAAM,uBAAuB,mtBAkB/B,CAAC;AAEN,eAAO,MAAM,uBAAuB,8mBAiB/B,CAAC;AAEN,eAAO,MAAM,oBAAoB,ytBAkB5B,CAAC;AAKN,eAAO,MAAM,gBAAgB,8JAK3B,CAAC;AAEH,eAAO,MAAM,oBAAoB,sYAU5B,CAAC;AAEN,eAAO,MAAM,iBAAiB,mWASzB,CAAC;AAEN,eAAO,MAAM,iBAAiB,yVASzB,CAAC;AAEN,eAAO,MAAM,4BAA4B,+XAQpC,CAAC;AAEN,eAAO,MAAM,sBAAsB,0XAQ9B,CAAC;AAEN,eAAO,MAAM,iCAAiC,6VAQzC,CAAC;AAEN,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,KAAG,MAK1D,CAAC"}
|
|
@@ -210,6 +210,7 @@ export const COMMON_PATH_SERVICES = `defineKnowledgeEntry({
|
|
|
210
210
|
scope: ['app'],
|
|
211
211
|
appliesWhen: ['generate-service'],
|
|
212
212
|
content: 'Service classes live in src/services/. One service per file.',
|
|
213
|
+
metadata: { path: 'src/services' },
|
|
213
214
|
})`;
|
|
214
215
|
export const COMMON_PATH_UTILS = `defineKnowledgeEntry({
|
|
215
216
|
id: 'paths.utils',
|
|
@@ -219,6 +220,7 @@ export const COMMON_PATH_UTILS = `defineKnowledgeEntry({
|
|
|
219
220
|
tags: ['paths', 'utils'],
|
|
220
221
|
appliesWhen: ['generate-utility'],
|
|
221
222
|
content: 'Pure helpers live in src/utils/. One function per file.',
|
|
223
|
+
metadata: { path: 'src/utils' },
|
|
222
224
|
})`;
|
|
223
225
|
export const COMMON_PATH_TESTS = `defineKnowledgeEntry({
|
|
224
226
|
id: 'paths.tests',
|
|
@@ -228,6 +230,7 @@ export const COMMON_PATH_TESTS = `defineKnowledgeEntry({
|
|
|
228
230
|
tags: ['paths', 'tests'],
|
|
229
231
|
appliesWhen: ['generate-test'],
|
|
230
232
|
content: 'Unit tests live under tests/, mirroring src/. Use *.spec.ts.',
|
|
233
|
+
metadata: { path: 'tests' },
|
|
231
234
|
})`;
|
|
232
235
|
export const COMMON_RULE_INTERFACE_PREFIX = `defineKnowledgeEntry({
|
|
233
236
|
id: 'typescript.interfaces.i-prefix',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize-files.d.ts","sourceRoot":"","sources":["../../src/emit/synthesize-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,IAAI,EACA,QAAQ,GACR,WAAW,GACX,OAAO,GACP,OAAO,GACP,WAAW,GACX,WAAW,GACX,MAAM,GACN,OAAO,GACP,cAAc,GACd,SAAS,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"synthesize-files.d.ts","sourceRoot":"","sources":["../../src/emit/synthesize-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,IAAI,EACA,QAAQ,GACR,WAAW,GACX,OAAO,GACP,OAAO,GACP,WAAW,GACX,WAAW,GACX,MAAM,GACN,OAAO,GACP,cAAc,GACd,SAAS,CAAC;CACf;AAqMD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAEzE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7D,GAAG,gBAAgB,EAAE,CAErB"}
|
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
// Self-contained preambles for each emitted file kind. Generated files
|
|
2
|
+
// must work in a brand-new downstream repo where no `@shrkcrft/*`
|
|
3
|
+
// packages are installed. The loaders (knowledge / templates / pipelines)
|
|
4
|
+
// are shape-agnostic — they accept any object with the required string
|
|
5
|
+
// fields — so we just need helpers + enum-like constants the snippets
|
|
6
|
+
// reference. See `packages/knowledge/src/load/typescript-knowledge-loader.ts`
|
|
7
|
+
// for the loader contract.
|
|
8
|
+
const KNOWLEDGE_HELPERS = `// Local helpers — keep this file self-contained (no @shrkcrft/* imports).
|
|
9
|
+
const KnowledgePriority = {
|
|
10
|
+
Critical: 'critical',
|
|
11
|
+
High: 'high',
|
|
12
|
+
Medium: 'medium',
|
|
13
|
+
Low: 'low',
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
const KnowledgeType = {
|
|
17
|
+
Rule: 'rule',
|
|
18
|
+
Path: 'path',
|
|
19
|
+
Template: 'template',
|
|
20
|
+
Architecture: 'architecture',
|
|
21
|
+
Technical: 'technical',
|
|
22
|
+
Business: 'business',
|
|
23
|
+
Command: 'command',
|
|
24
|
+
Environment: 'environment',
|
|
25
|
+
Dependency: 'dependency',
|
|
26
|
+
Feature: 'feature',
|
|
27
|
+
Task: 'task',
|
|
28
|
+
Warning: 'warning',
|
|
29
|
+
Decision: 'decision',
|
|
30
|
+
Convention: 'convention',
|
|
31
|
+
Workflow: 'workflow',
|
|
32
|
+
Testing: 'testing',
|
|
33
|
+
Security: 'security',
|
|
34
|
+
Deployment: 'deployment',
|
|
35
|
+
Integration: 'integration',
|
|
36
|
+
Custom: 'custom',
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
function defineKnowledgeEntry<T>(entry: T): T {
|
|
40
|
+
return entry;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const TEMPLATE_HELPERS = `// Local helpers — keep this file self-contained (no @shrkcrft/* imports).
|
|
44
|
+
function defineTemplate<T>(template: T): T {
|
|
45
|
+
return template;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function kebab(s: string): string {
|
|
49
|
+
return s
|
|
50
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
51
|
+
.replace(/[^A-Za-z0-9]+/g, '-')
|
|
52
|
+
.toLowerCase();
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const PIPELINE_HELPERS = `// Local helpers — keep this file self-contained (no @shrkcrft/* imports).
|
|
56
|
+
function definePipeline<T>(pipeline: T): T {
|
|
57
|
+
return pipeline;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
1
60
|
function recordToMap(v) {
|
|
2
61
|
if (!v)
|
|
3
62
|
return new Map();
|
|
@@ -11,48 +70,47 @@ function listBlock(items, indent = ' ') {
|
|
|
11
70
|
return items.map((expr) => indent + expr.replace(/\n/g, `\n${indent}`)).join(',\n') + ',\n';
|
|
12
71
|
}
|
|
13
72
|
function knowledgeFile(items) {
|
|
14
|
-
return (
|
|
15
|
-
'
|
|
73
|
+
return (KNOWLEDGE_HELPERS +
|
|
74
|
+
'\nconst knowledge = [\n' +
|
|
16
75
|
listBlock(items) +
|
|
17
76
|
'];\n\n' +
|
|
18
77
|
'export default knowledge;\n');
|
|
19
78
|
}
|
|
20
79
|
function rulesFile(items) {
|
|
21
|
-
return (
|
|
22
|
-
'
|
|
80
|
+
return (KNOWLEDGE_HELPERS +
|
|
81
|
+
'\nconst rules = [\n' +
|
|
23
82
|
listBlock(items) +
|
|
24
83
|
'];\n\n' +
|
|
25
84
|
'export default rules;\n');
|
|
26
85
|
}
|
|
27
86
|
function pathsFile(items) {
|
|
28
|
-
return (
|
|
29
|
-
'
|
|
87
|
+
return (KNOWLEDGE_HELPERS +
|
|
88
|
+
'\nconst paths = [\n' +
|
|
30
89
|
listBlock(items) +
|
|
31
90
|
'];\n\n' +
|
|
32
91
|
'export default paths;\n');
|
|
33
92
|
}
|
|
34
93
|
function templatesFile(items) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return ("import { defineTemplate } from '@shrkcrft/templates';\n\n" +
|
|
38
|
-
'function kebab(s: string): string {\n' +
|
|
39
|
-
" return s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/[^A-Za-z0-9]+/g, '-').toLowerCase();\n" +
|
|
40
|
-
'}\n\n' +
|
|
41
|
-
'const templates = [\n' +
|
|
94
|
+
return (TEMPLATE_HELPERS +
|
|
95
|
+
'\nconst templates = [\n' +
|
|
42
96
|
listBlock(items) +
|
|
43
97
|
'];\n\n' +
|
|
44
98
|
'export default templates;\n');
|
|
45
99
|
}
|
|
46
100
|
function pipelinesFile(items) {
|
|
47
|
-
return (
|
|
48
|
-
'
|
|
101
|
+
return (PIPELINE_HELPERS +
|
|
102
|
+
'\nconst pipelines = [\n' +
|
|
49
103
|
listBlock(items) +
|
|
50
104
|
'];\n\n' +
|
|
51
105
|
'export default pipelines;\n');
|
|
52
106
|
}
|
|
53
107
|
function configFile(preset) {
|
|
54
108
|
// Generic config that points at the standard knowledge/rules/paths/etc.
|
|
55
|
-
// files. Consumers can tailor it later.
|
|
109
|
+
// files. Consumers can tailor it later. Plain default-exported object —
|
|
110
|
+
// the config loader (packages/config/src/config-loader.ts) validates the
|
|
111
|
+
// shape via zod and accepts an object literal as well as a
|
|
112
|
+
// `defineSharkCraftConfig()`-wrapped value, so the generated file does
|
|
113
|
+
// not need to import anything from `@shrkcrft/*`.
|
|
56
114
|
const filesByKind = inferFiles(preset);
|
|
57
115
|
const knowledgeFiles = filesByKind.has('knowledge.ts') ? ['knowledge.ts'] : [];
|
|
58
116
|
const ruleFiles = filesByKind.has('rules.ts') ? ['rules.ts'] : [];
|
|
@@ -67,7 +125,8 @@ function configFile(preset) {
|
|
|
67
125
|
? ` surface: { profile: ${JSON.stringify(preset.surfaceProfile)} },\n`
|
|
68
126
|
: '';
|
|
69
127
|
return (`// Generated by \`shrk presets apply ${preset.id}\`.\n` +
|
|
70
|
-
'// Edit freely. SharkCraft does not regenerate this file.\n
|
|
128
|
+
'// Edit freely. SharkCraft does not regenerate this file.\n' +
|
|
129
|
+
'// Plain default export — no @shrkcrft/* import required.\n\n' +
|
|
71
130
|
'const config = {\n' +
|
|
72
131
|
` projectName: 'shrk-project',\n` +
|
|
73
132
|
` description: ${JSON.stringify(preset.description)},\n` +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/presets",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"description": "SharkCraft presets: reusable project setups (knowledge/rules/paths/templates/pipelines/docs) that can be applied to a target repo through the CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
46
|
-
"@shrkcrft/knowledge": "^0.1.0-alpha.
|
|
47
|
-
"@shrkcrft/workspace": "^0.1.0-alpha.
|
|
45
|
+
"@shrkcrft/core": "^0.1.0-alpha.4",
|
|
46
|
+
"@shrkcrft/knowledge": "^0.1.0-alpha.4",
|
|
47
|
+
"@shrkcrft/workspace": "^0.1.0-alpha.4"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|