@morda-dev/create-sdk 1.0.1 → 1.1.1

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.
Files changed (120) hide show
  1. package/README.md +51 -0
  2. package/bin/create-sdk.js +185 -31
  3. package/package.json +30 -3
  4. package/template/.github/workflows/ci.yml +30 -35
  5. package/template/api-extractor.json +6 -6
  6. package/template/etc/project-template.api.md +32 -32
  7. package/template/package.json +14 -5
  8. package/template/src/index.ts +8 -2
  9. package/template/src/modules/user.ts +23 -4
  10. package/template/src/types/user.ts +11 -3
  11. package/template/.editorconfig +0 -0
  12. package/template/.github/CODEOWNERS +0 -2
  13. package/template/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  14. package/template/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  15. package/template/.github/dependabot.yml +0 -18
  16. package/template/.github/pull_request_template.md +0 -25
  17. package/template/.github/workflows/auto-release.yml +0 -77
  18. package/template/.github/workflows/deploy-pages.yml +0 -73
  19. package/template/.github/workflows/docs-ci.yml +0 -38
  20. package/template/.github/workflows/docs.yml +0 -19
  21. package/template/.github/workflows/release.yml +0 -51
  22. package/template/.husky/commit-msg +0 -4
  23. package/template/.husky/pre-commit +0 -4
  24. package/template/.prettierrc +0 -0
  25. package/template/CHANGELOG.md +0 -49
  26. package/template/CODE_OF_CONDUCT.md +0 -40
  27. package/template/CONTRIBUTING.md +0 -38
  28. package/template/SECURITY.md +0 -16
  29. package/template/TEST_DEPLOY.md +0 -0
  30. package/template/ci-cd.md +0 -93
  31. package/template/commitlint.config.cjs +0 -3
  32. package/template/coverage/base.css +0 -224
  33. package/template/coverage/block-navigation.js +0 -87
  34. package/template/coverage/clover.xml +0 -6
  35. package/template/coverage/coverage-final.json +0 -1
  36. package/template/coverage/favicon.png +0 -0
  37. package/template/coverage/index.html +0 -101
  38. package/template/coverage/prettify.css +0 -1
  39. package/template/coverage/prettify.js +0 -2
  40. package/template/coverage/sort-arrow-sprite.png +0 -0
  41. package/template/coverage/sorter.js +0 -210
  42. package/template/docs/api/README.md +0 -5
  43. package/template/docs/api-auto/README.md +0 -5
  44. package/template/docs/index.html +0 -73
  45. package/template/docs/index.md +0 -28
  46. package/template/docusaurus-build/.github/workflows/deploy-docs.yml +0 -46
  47. package/template/docusaurus-build/.github/workflows/deploy-pages.yml +0 -43
  48. package/template/docusaurus-build/README.md +0 -44
  49. package/template/docusaurus-build/blog/authors.yml +0 -34
  50. package/template/docusaurus-build/blog/hello-world.md +0 -9
  51. package/template/docusaurus-build/docs/ci-cd.md +0 -62
  52. package/template/docusaurus-build/docs/conventions.md +0 -50
  53. package/template/docusaurus-build/docs/folder-structure.md +0 -24
  54. package/template/docusaurus-build/docs/getting-started.md +0 -24
  55. package/template/docusaurus-build/docs/intro.md +0 -14
  56. package/template/docusaurus-build/docs/project-architecture.md +0 -125
  57. package/template/docusaurus-build/docs/project-template/architecture.md +0 -82
  58. package/template/docusaurus-build/docs/project-template/getting-started.md +0 -24
  59. package/template/docusaurus-build/docs/project-template/overview.md +0 -78
  60. package/template/docusaurus-build/docs/project-template/structure.md +0 -145
  61. package/template/docusaurus-build/docs/scripts.md +0 -42
  62. package/template/docusaurus-build/docs/testing.md +0 -30
  63. package/template/docusaurus-build/docusaurus-build/sidebars.ts +0 -30
  64. package/template/docusaurus-build/docusaurus-build/tsconfig.json +0 -8
  65. package/template/docusaurus-build/docusaurus-build/typedoc.tsconfig.json +0 -28
  66. package/template/docusaurus-build/docusaurus.config.ts +0 -129
  67. package/template/docusaurus-build/package-lock.json +0 -18235
  68. package/template/docusaurus-build/package.json +0 -51
  69. package/template/docusaurus-build/project-template/README.md +0 -44
  70. package/template/docusaurus-build/project-template/src/index.ts +0 -4
  71. package/template/docusaurus-build/project-template/src/modules/user.ts +0 -20
  72. package/template/docusaurus-build/project-template/src/types/user.ts +0 -5
  73. package/template/docusaurus-build/sidebars.ts +0 -20
  74. package/template/docusaurus-build/src/components/HomepageFeatures/index.tsx +0 -71
  75. package/template/docusaurus-build/src/components/HomepageFeatures/styles.module.css +0 -11
  76. package/template/docusaurus-build/src/css/custom.css +0 -30
  77. package/template/docusaurus-build/src/pages/index.module.css +0 -23
  78. package/template/docusaurus-build/src/pages/index.tsx +0 -52
  79. package/template/docusaurus-build/src/pages/markdown-page.md +0 -7
  80. package/template/docusaurus-build/static/.nojekyll +0 -0
  81. package/template/docusaurus-build/static/api/.nojekyll +0 -1
  82. package/template/docusaurus-build/static/api/assets/hierarchy.js +0 -1
  83. package/template/docusaurus-build/static/api/assets/highlight.css +0 -22
  84. package/template/docusaurus-build/static/api/assets/icons.js +0 -18
  85. package/template/docusaurus-build/static/api/assets/icons.svg +0 -1
  86. package/template/docusaurus-build/static/api/assets/main.js +0 -60
  87. package/template/docusaurus-build/static/api/assets/navigation.js +0 -1
  88. package/template/docusaurus-build/static/api/assets/search.js +0 -1
  89. package/template/docusaurus-build/static/api/assets/style.css +0 -1633
  90. package/template/docusaurus-build/static/api/functions/modules_user.getUser.html +0 -1
  91. package/template/docusaurus-build/static/api/functions/modules_user.sumAges.html +0 -1
  92. package/template/docusaurus-build/static/api/hierarchy.html +0 -1
  93. package/template/docusaurus-build/static/api/index.html +0 -1
  94. package/template/docusaurus-build/static/api/modules/index.html +0 -1
  95. package/template/docusaurus-build/static/api/modules/modules_user.html +0 -1
  96. package/template/docusaurus-build/static/api/modules/types_user.html +0 -1
  97. package/template/docusaurus-build/static/api/types/types_user.ApiResult.html +0 -3
  98. package/template/docusaurus-build/static/api/types/types_user.User.html +0 -4
  99. package/template/docusaurus-build/static/img/docusaurus-social-card.jpg +0 -0
  100. package/template/docusaurus-build/static/img/docusaurus.png +0 -0
  101. package/template/docusaurus-build/static/img/favicon.ico +0 -0
  102. package/template/docusaurus-build/static/img/logo.svg +0 -1
  103. package/template/docusaurus-build/static/img/undraw_docusaurus_mountain.svg +0 -171
  104. package/template/docusaurus-build/static/img/undraw_docusaurus_react.svg +0 -170
  105. package/template/docusaurus-build/static/img/undraw_docusaurus_tree.svg +0 -40
  106. package/template/docusaurus-build/tsconfig.json +0 -8
  107. package/template/docusaurus-build/typedoc.json +0 -14
  108. package/template/docusaurus-build/typedoc.tsconfig.json +0 -7
  109. package/template/eslint.config.mjs +0 -72
  110. package/template/morda-dev-project-template-0.1.1.tgz +0 -0
  111. package/template/package-lock.json +0 -45
  112. package/template/scripts/commitlint-runner.mjs +0 -10
  113. package/template/test.ts +0 -4
  114. package/template/tests/example.test.js +0 -3
  115. package/template/tests/public-api.snapshot.test.ts +0 -13
  116. package/template/tests/public-api.test.ts +0 -58
  117. package/template/tests/user.test.ts +0 -16
  118. package/template/tsconfig.eslint.json +0 -14
  119. package/template/typedoc.json +0 -6
  120. package/template/vitest.config.ts +0 -12
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # create-sdk
2
+
3
+ Scaffold a production-ready TypeScript SDK with a strict public API.
4
+
5
+ ## 🚀 Quick start
6
+
7
+ ```bash
8
+ npx @morda-dev/create-sdk my-sdk
9
+ cd my-sdk
10
+ npm install
11
+ npm run build
12
+ ```
13
+
14
+ ## ✨ What you get
15
+
16
+ ⚡ TypeScript + ESM out of the box
17
+
18
+ 🔒 Strict public API enforcement (API Extractor)
19
+
20
+ 🧪 CI-ready project structure
21
+
22
+ 📦 Clean SDK architecture
23
+
24
+ 🚫 No accidental exports
25
+
26
+ ## 📁 Project structure
27
+ src/
28
+ index.ts # public API surface
29
+ modules/ # internal implementation
30
+ types/ # public types
31
+
32
+ Only symbols exported from src/index.ts are considered public.
33
+
34
+ ## 📜 Available scripts
35
+ npm run build # build the SDK
36
+ npm run api:check # validate public API
37
+
38
+ ## 🧠 Philosophy
39
+
40
+ This CLI helps you build SDKs with a stable and explicit public API.
41
+
42
+ Anything not exported from src/index.ts is treated as private by default.
43
+ This prevents accidental breaking changes and enforces long-term stability.
44
+
45
+ ## ⚙️ Requirements
46
+
47
+ Node.js >= 18
48
+
49
+ ## 📄 License
50
+
51
+ ISC
package/bin/create-sdk.js CHANGED
@@ -1,63 +1,172 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import fs from "fs";
4
4
  import path from "path";
5
+ import process from "process";
5
6
  import { fileURLToPath } from "url";
7
+ import { execSync } from "child_process";
8
+ import prompts from "prompts";
6
9
 
7
- /**
8
- * Resolve __dirname in ESM
10
+ /* ============================================================================
11
+ * Environment checks
12
+ * ============================================================================
9
13
  */
14
+
15
+ const REQUIRED_NODE_MAJOR = 18;
16
+ const CURRENT_NODE_MAJOR = Number(process.versions.node.split(".")[0]);
17
+
18
+ if (CURRENT_NODE_MAJOR < REQUIRED_NODE_MAJOR) {
19
+ console.error(
20
+ `❌ Node.js ${REQUIRED_NODE_MAJOR}+ is required.\n` +
21
+ ` You are using Node.js ${process.versions.node}`
22
+ );
23
+ process.exit(1);
24
+ }
25
+
26
+ /* ============================================================================
27
+ * CLI args & flags
28
+ * ============================================================================
29
+ */
30
+
31
+ const rawArgs = process.argv.slice(2);
32
+
33
+ const flags = {
34
+ yes: rawArgs.includes("--yes"),
35
+ noGit: rawArgs.includes("--no-git"),
36
+ noInstall: rawArgs.includes("--no-install"),
37
+ };
38
+
39
+ if (rawArgs.includes("--version") || rawArgs.includes("-v")) {
40
+ console.log("create-sdk v1.1.0");
41
+ process.exit(0);
42
+ }
43
+
44
+ if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
45
+ console.log(`
46
+ create-sdk — scaffold a production-ready TypeScript SDK
47
+
48
+ Usage:
49
+ npx @morda-dev/create-sdk <project-name>
50
+
51
+ Options:
52
+ --yes Skip prompts and use defaults
53
+ --no-git Do not initialize git repository
54
+ --no-install Do not install dependencies
55
+ --help, -h Show this help
56
+ --version, -v Show version
57
+
58
+ Example:
59
+ npx @morda-dev/create-sdk my-sdk
60
+ npx @morda-dev/create-sdk my-sdk --yes --no-install
61
+ `);
62
+ process.exit(0);
63
+ }
64
+
65
+ /* ============================================================================
66
+ * Paths
67
+ * ============================================================================
68
+ */
69
+
10
70
  const __filename = fileURLToPath(import.meta.url);
11
71
  const __dirname = path.dirname(__filename);
72
+ const templateDir = path.resolve(__dirname, "../template");
12
73
 
13
- /**
14
- * Project name from CLI args
74
+ /* ============================================================================
75
+ * Project name & interactive flow
76
+ * ============================================================================
15
77
  */
16
- const projectName = process.argv[2];
78
+
79
+ const argProjectName = rawArgs.find((a) => !a.startsWith("-"));
80
+
81
+ let projectName;
82
+ let initGit = !flags.noGit;
83
+ let installDeps = !flags.noInstall;
84
+
85
+ if (flags.yes && argProjectName) {
86
+ projectName = argProjectName;
87
+ } else if (!argProjectName) {
88
+ const answers = await prompts(
89
+ [
90
+ {
91
+ type: "text",
92
+ name: "name",
93
+ message: "Project name:",
94
+ validate: (v) => (v ? true : "Project name is required"),
95
+ },
96
+ {
97
+ type: "confirm",
98
+ name: "initGit",
99
+ message: "Initialize git repository?",
100
+ initial: true,
101
+ },
102
+ {
103
+ type: "confirm",
104
+ name: "installDeps",
105
+ message: "Install dependencies now?",
106
+ initial: false,
107
+ },
108
+ ],
109
+ {
110
+ onCancel: () => {
111
+ console.log("\n❌ Cancelled");
112
+ process.exit(1);
113
+ },
114
+ }
115
+ );
116
+
117
+ projectName = answers.name;
118
+ initGit = answers.initGit;
119
+ installDeps = answers.installDeps;
120
+ } else {
121
+ projectName = argProjectName;
122
+ }
17
123
 
18
124
  if (!projectName) {
19
- console.error("❌ Please provide a project name");
20
- console.error(" Usage: npx create-sdk my-sdk");
125
+ console.error("❌ Project name is required");
21
126
  process.exit(1);
22
127
  }
23
128
 
24
- /**
25
- * Paths
129
+ /* ============================================================================
130
+ * Target directory
131
+ * ============================================================================
26
132
  */
27
- const targetDir = path.resolve(process.cwd(), projectName);
28
- const templateDir = path.resolve(__dirname, "../template");
29
133
 
30
- /**
134
+ const dirName = projectName.startsWith("@")
135
+ ? projectName.split("/")[1]
136
+ : projectName;
137
+
138
+ const targetDir = path.resolve(process.cwd(), dirName);
139
+
140
+ /* ============================================================================
31
141
  * Safety checks
142
+ * ============================================================================
32
143
  */
144
+
33
145
  if (!fs.existsSync(templateDir)) {
34
- console.error("❌ Template directory not found:");
35
- console.error(" ", templateDir);
146
+ console.error("❌ Template directory not found:", templateDir);
36
147
  process.exit(1);
37
148
  }
38
149
 
39
150
  if (fs.existsSync(targetDir)) {
40
- console.error(`❌ Directory "${projectName}" already exists`);
151
+ console.error(`❌ Directory "${dirName}" already exists`);
41
152
  process.exit(1);
42
153
  }
43
154
 
44
- /**
45
- * Create project
155
+ /* ============================================================================
156
+ * Scaffold project
157
+ * ============================================================================
46
158
  */
159
+
47
160
  console.log("🚀 Creating SDK:", projectName);
48
161
 
49
162
  copyDir(templateDir, targetDir);
50
163
 
51
- /**
164
+ /* ============================================================================
52
165
  * Update package.json
166
+ * ============================================================================
53
167
  */
54
- const pkgPath = path.join(targetDir, "package.json");
55
-
56
- if (!fs.existsSync(pkgPath)) {
57
- console.error("❌ package.json not found in template");
58
- process.exit(1);
59
- }
60
168
 
169
+ const pkgPath = path.join(targetDir, "package.json");
61
170
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
62
171
 
63
172
  pkg.name = projectName;
@@ -66,18 +175,63 @@ delete pkg.private;
66
175
 
67
176
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
68
177
 
69
- /**
178
+ /* ============================================================================
179
+ * Update README title
180
+ * ============================================================================
181
+ */
182
+
183
+ const readmePath = path.join(targetDir, "README.md");
184
+
185
+ if (fs.existsSync(readmePath)) {
186
+ const updated = fs
187
+ .readFileSync(readmePath, "utf8")
188
+ .replace(/^# .*/m, `# ${projectName}`);
189
+
190
+ fs.writeFileSync(readmePath, updated);
191
+ }
192
+
193
+ /* ============================================================================
194
+ * Git init
195
+ * ============================================================================
196
+ */
197
+
198
+ if (initGit) {
199
+ try {
200
+ execSync("git init", { cwd: targetDir, stdio: "ignore" });
201
+ } catch {}
202
+ }
203
+
204
+ /* ============================================================================
205
+ * Install dependencies
206
+ * ============================================================================
207
+ */
208
+
209
+ if (installDeps) {
210
+ try {
211
+ execSync("npm install", { cwd: targetDir, stdio: "inherit" });
212
+ } catch {
213
+ console.warn("⚠️ Failed to install dependencies");
214
+ }
215
+ }
216
+
217
+ /* ============================================================================
70
218
  * Done
219
+ * ============================================================================
71
220
  */
72
- console.log("✅ SDK created successfully!");
221
+
222
+ console.log("");
223
+ console.log("🎉 SDK scaffolded successfully!");
73
224
  console.log("");
74
225
  console.log("Next steps:");
75
- console.log(` cd ${projectName}`);
76
- console.log(" npm install");
226
+ console.log(` cd ${dirName}`);
227
+ if (!installDeps) console.log(" npm install");
77
228
  console.log(" npm run build");
229
+ console.log("");
230
+ console.log("Happy hacking 🚀");
78
231
 
79
- /**
80
- * ===== Helpers =====
232
+ /* ============================================================================
233
+ * Helpers
234
+ * ============================================================================
81
235
  */
82
236
 
83
237
  function copyDir(src, dest) {
package/package.json CHANGED
@@ -1,14 +1,41 @@
1
1
  {
2
2
  "name": "@morda-dev/create-sdk",
3
- "version": "1.0.1",
4
- "description": "CLI to scaffold a production-ready TypeScript SDK",
3
+ "version": "1.1.1",
4
+ "description": "CLI to scaffold a production-ready TypeScript SDK with a strict public API",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-sdk": "./bin/create-sdk.js"
8
8
  },
9
9
  "files": [
10
10
  "bin",
11
- "template"
11
+ "template",
12
+ "README.md"
12
13
  ],
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/mordaHQ/create-sdk.git"
20
+ },
21
+ "homepage": "https://github.com/mordaHQ/create-sdk",
22
+ "bugs": {
23
+ "url": "https://github.com/mordaHQ/create-sdk/issues"
24
+ },
25
+ "keywords": [
26
+ "create-sdk",
27
+ "typescript",
28
+ "sdk",
29
+ "cli",
30
+ "scaffold",
31
+ "api-extractor",
32
+ "library"
33
+ ],
34
+ "scripts": {
35
+ "test:smoke": "node ./bin/create-sdk.js __tmp-smoke-sdk --yes --no-install --no-git && node -e \"import('fs').then(fs => fs.rmSync('__tmp-smoke-sdk', { recursive: true, force: true }))\""
36
+ },
37
+ "dependencies": {
38
+ "prompts": "^2.4.2"
39
+ },
13
40
  "license": "ISC"
14
41
  }
@@ -1,35 +1,30 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
-
8
- jobs:
9
- build:
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - name: Checkout repository
14
- uses: actions/checkout@v4
15
-
16
- - name: Setup Node.js
17
- uses: actions/setup-node@v4
18
- with:
19
- node-version: 20
20
- cache: npm
21
-
22
- - name: Install dependencies
23
- run: npm ci
24
-
25
- - name: Lint
26
- run: npm run lint
27
-
28
- - name: Typecheck
29
- run: npm run typecheck
30
-
31
- - name: Build
32
- run: npm run build
33
-
34
- - name: Test
35
- run: npm run test
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ main ]
6
+ push:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ build-and-api-check:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout repo
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Node
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: 20
21
+ cache: npm
22
+
23
+ - name: Install dependencies
24
+ run: npm ci
25
+
26
+ - name: Build
27
+ run: npm run build
28
+
29
+ - name: API Extractor check
30
+ run: npm run api:check
@@ -5,16 +5,15 @@
5
5
 
6
6
  "apiReport": {
7
7
  "enabled": true,
8
- "reportFolder": "./etc",
9
- "reportFileName": "project-template.api.md"
8
+ "reportFileName": "project-template.api.md",
9
+ "reportFolder": "./etc"
10
10
  },
11
11
 
12
- "dtsRollup": {
13
- "enabled": true,
14
- "untrimmedFilePath": "./dist/project-template.d.ts"
12
+ "docModel": {
13
+ "enabled": false
15
14
  },
16
15
 
17
- "docModel": {
16
+ "dtsRollup": {
18
17
  "enabled": false
19
18
  },
20
19
 
@@ -24,6 +23,7 @@
24
23
  "logLevel": "warning"
25
24
  }
26
25
  },
26
+
27
27
  "extractorMessageReporting": {
28
28
  "default": {
29
29
  "logLevel": "warning"
@@ -1,32 +1,32 @@
1
- ## API Report File for "project-template"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
- // @public
7
- export type ApiResult<T> =
8
- | {
9
- ok: true;
10
- data: T;
11
- }
12
- | {
13
- ok: false;
14
- error: string;
15
- };
16
-
17
- // @public
18
- export function getUser(id: number): ApiResult<User>;
19
-
20
- // @public
21
- export function sumAges(users: User[]): number;
22
-
23
- // @public
24
- export interface User {
25
- // (undocumented)
26
- age: number;
27
- // (undocumented)
28
- id: number;
29
- // (undocumented)
30
- name: string;
31
- }
32
- ```
1
+ ## API Report File for "@morda-dev/project-template"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ // @public
8
+ export type ApiResult<T> = {
9
+ success: true;
10
+ data: T;
11
+ } | {
12
+ success: false;
13
+ error: string;
14
+ };
15
+
16
+ // @public
17
+ export function getUser(id: number): ApiResult<User>;
18
+
19
+ // @public
20
+ export function sumAges(users: User[]): number;
21
+
22
+ // @public
23
+ export interface User {
24
+ // (undocumented)
25
+ age: number;
26
+ // (undocumented)
27
+ id: number;
28
+ // (undocumented)
29
+ name: string;
30
+ }
31
+
32
+ ```
@@ -4,32 +4,41 @@
4
4
  "description": "Production-ready TypeScript SDK template with a strict public API",
5
5
  "license": "ISC",
6
6
  "type": "module",
7
+
7
8
  "main": "./dist/index.js",
8
9
  "types": "./dist/index.d.ts",
10
+
9
11
  "exports": {
10
12
  ".": {
11
13
  "import": "./dist/index.js",
12
14
  "types": "./dist/index.d.ts"
13
15
  }
14
16
  },
17
+
15
18
  "files": [
16
- "dist"
19
+ "dist",
20
+ "etc"
17
21
  ],
22
+
18
23
  "sideEffects": false,
24
+
19
25
  "engines": {
20
26
  "node": ">=18"
21
27
  },
28
+
22
29
  "repository": {
23
30
  "type": "git",
24
31
  "url": "https://github.com/mordaHQ/project-template.git"
25
32
  },
33
+
26
34
  "scripts": {
27
- "build": "tsc -p tsconfig.build.json"
35
+ "build": "tsc -p tsconfig.build.json",
36
+ "api:update": "api-extractor run --local",
37
+ "api:check": "api-extractor run"
28
38
  },
39
+
29
40
  "devDependencies": {
41
+ "@microsoft/api-extractor": "^7.55.2",
30
42
  "typescript": "^5.9.3"
31
- },
32
- "dependencies": {
33
- "@morda-dev/project-template": "^0.1.1"
34
43
  }
35
44
  }
@@ -1,7 +1,11 @@
1
1
  /**
2
- * Project Template — Public API
3
- *
4
2
  * @packageDocumentation
3
+ *
4
+ * Production-ready TypeScript SDK template.
5
+ *
6
+ * This file defines the public API surface of the package.
7
+ * Only symbols exported from this file are considered stable
8
+ * and part of the public contract.
5
9
  */
6
10
 
7
11
  /* ============================================================================
@@ -9,6 +13,7 @@
9
13
  * ============================================================================
10
14
  */
11
15
 
16
+ /** @public */
12
17
  export type { User, ApiResult } from "./types/user.js";
13
18
 
14
19
  /* ============================================================================
@@ -16,4 +21,5 @@ export type { User, ApiResult } from "./types/user.js";
16
21
  * ============================================================================
17
22
  */
18
23
 
24
+ /** @public */
19
25
  export { getUser, sumAges } from "./modules/user.js";
@@ -1,12 +1,31 @@
1
- import type { User, ApiResult } from "../types/user.js";
1
+ import { ApiResult, User } from "../types/user.js";
2
2
 
3
+ /**
4
+ * @public
5
+ * Get a user by id
6
+ */
3
7
  export function getUser(id: number): ApiResult<User> {
8
+ if (id <= 0) {
9
+ return {
10
+ success: false,
11
+ error: "Invalid user id",
12
+ };
13
+ }
14
+
4
15
  return {
5
- ok: true,
6
- data: { id, name: "John", age: 30 },
16
+ success: true,
17
+ data: {
18
+ id,
19
+ name: "John Doe",
20
+ age: 30,
21
+ },
7
22
  };
8
23
  }
9
24
 
25
+ /**
26
+ * @public
27
+ * Sum ages of users
28
+ */
10
29
  export function sumAges(users: User[]): number {
11
- return users.reduce((sum, u) => sum + u.age, 0);
30
+ return users.reduce((sum, user) => sum + user.age, 0);
12
31
  }
@@ -1,9 +1,17 @@
1
- export interface User {
1
+ /**
2
+ * @public
3
+ * User entity
4
+ */
5
+ export interface User {
2
6
  id: number;
3
7
  name: string;
4
8
  age: number;
5
9
  }
6
10
 
11
+ /**
12
+ * @public
13
+ * Generic API result
14
+ */
7
15
  export type ApiResult<T> =
8
- | { ok: true; data: T }
9
- | { ok: false; error: string };
16
+ | { success: true; data: T }
17
+ | { success: false; error: string };
Binary file
@@ -1,2 +0,0 @@
1
- # Автоматический выбор ревьювера для всех файлов
2
- * @mordaHQ