@langpkg/mcs_gen 0.0.2 → 0.0.3
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/README.md +1 -1
- package/dist/index.cjs +213 -0
- package/dist/index.d.cts +93 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +213 -0
- package/package.json +2 -2
- package/assets/img/line.png +0 -0
- package/assets/img/logo.png +0 -0
- package/docs/.gitkeep +0 -0
- package/eslint.config.mjs +0 -89
- package/src/common/index.ts +0 -112
- package/src/common/types.ts +0 -69
- package/src/gen/json/index.ts +0 -13
- package/src/gen/json/package_json.ts +0 -97
- package/src/gen/json/tsconfig.ts +0 -59
- package/src/gen/json/vscode_settings.ts +0 -67
- package/src/gen/md/index.ts +0 -11
- package/src/gen/md/readme.ts +0 -84
- package/src/gen/text/gitignore.ts +0 -43
- package/src/gen/text/index.ts +0 -12
- package/src/gen/text/license.ts +0 -73
- package/src/gen/ts/eslint_config.ts +0 -115
- package/src/gen/ts/index.ts +0 -14
- package/src/gen/ts/source_index.ts +0 -54
- package/src/gen/ts/test_index.ts +0 -54
- package/src/gen/ts/tsup_config.ts +0 -65
- package/src/gen/ts/utils.ts +0 -55
- package/src/index.ts +0 -69
- package/test/.gitkeep +0 -0
- package/test/index.test.ts +0 -23
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -36
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<p align="center" style="font-style:italic; color:gray;">
|
|
12
12
|
----------------<br>
|
|
13
13
|
</p>
|
|
14
|
-
<img data="version" src="https://img.shields.io/badge/v-0.0.
|
|
14
|
+
<img data="version" src="https://img.shields.io/badge/v-0.0.3-black"/>
|
|
15
15
|
<a href="https://github.com/langpkg/pkg"><img src="https://img.shields.io/badge/part of-langpkg/pkg-black"/></a>
|
|
16
16
|
<br>
|
|
17
17
|
<img src="https://img.shields.io/badge/coverage-~%25-brightgreen" alt="Test Coverage" />
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _mcs_fmt = require('@langpkg/mcs_fmt');function m(){let e=_mcs_fmt.formatJSON.call(void 0, JSON.stringify({"files.exclude":{"**/.git":!0,"**/.svn":!0,"**/.hg":!0,"**/.DS_Store":!0,"**/Thumbs.db":!0,"eslint.config.mjs":!0,"bun.lock":!0,"package-lock.json":!0,LICENSE:!0,".gitignore":!0,".gitattributes":!0,".npmignore":!0,node_modules:!0,"tsup.config.ts":!0,"tsconfig.json":!0},"hide-files.files":["eslint.config.mjs",".pkg",".vscode","bun.lock","package-lock.json","LICENSE",".gitignore",".gitattributes",".npmignore","node_modules","tsup.config.ts","tsconfig.json"]}),".vscode/settings.json");if(_optionalChain([e, 'access', _ => _.errors, 'optionalAccess', _2 => _2.length]))throw console.error("Error formatting vscode settings:",JSON.stringify(e.errors,null,2)),new Error("Failed to generate vscode settings due to formatting errors.");return e.formatted+`
|
|
2
|
+
`}function u(n,e){let t=e.org&&e.repoName?`https://github.com/${e.org}/${e.repoName}`:"",o=[e.author.name,e.author.email?`<${e.author.email}>`:""].filter(Boolean).join(" "),r={name:e.name,version:e.version,description:e.description,keywords:[],license:e.license,author:o||"",repository:t?{type:"git",url:`git+${t}.git`}:"",type:"module",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},scripts:{},dependencies:{},devDependencies:{"@eslint/js":"^9.39.4","@stylistic/eslint-plugin":"^5.10.0","@types/bun":"^1.3.13","@types/node":"^25.7.0","bun-plugin-dts":"^0.3.0","bun-types":"^1.3.13","ts-node":"^10.9.2",tsup:"^8.5.1",typescript:"^5.9.3","typescript-eslint":"^8.59.3"}};if(n==="cli"){let a=e.name.replace(/^@[^/]+\//,""),g={};for(let[l,j]of Object.entries(r))g[l]=j,l==="type"&&(g.bin={[a]:"./dist/index.js"},g.pkg={type:"cli"});Object.keys(r).forEach(l=>delete r[l]),Object.assign(r,g)}else r.pkg={type:"lib"};let c=_mcs_fmt.formatJSON.call(void 0, JSON.stringify(r),"package.json");if(_optionalChain([c, 'access', _3 => _3.errors, 'optionalAccess', _4 => _4.length]))throw console.error("Error formatting package.json:",JSON.stringify(c.errors,null,2)),new Error("Failed to generate package.json due to formatting errors.");return c.formatted+`
|
|
3
|
+
`}function p(n){let t=_mcs_fmt.formatJSON.call(void 0, JSON.stringify({compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",lib:["DOM","ES2020","ESNext"],types:["node"],declaration:n==="pkg",outDir:"./dist",strict:!0,esModuleInterop:!0,skipLibCheck:!0,forceConsistentCasingInFileNames:!0,resolveJsonModule:!0,isolatedModules:!0,allowImportingTsExtensions:!0,noEmit:!0,ignoreDeprecations:"6.0"},include:["src","test"],exclude:["node_modules","dist"]}),"tsconfig.json");if(_optionalChain([t, 'access', _5 => _5.errors, 'optionalAccess', _6 => _6.length]))throw console.error("Error formatting tsconfig.json:",JSON.stringify(t.errors,null,2)),new Error("Failed to generate tsconfig.json due to formatting errors.");return t.formatted+`
|
|
4
|
+
`}function s(n,e,t=!0){let o=t?`
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
`:"",r="// \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 "+n+` \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
8
|
+
|
|
9
|
+
`,c=`// \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
10
|
+
`;return e=e.split(`
|
|
11
|
+
`).map(a=>a===""?a:" "+a).join(`
|
|
12
|
+
`),o+r+e+`
|
|
13
|
+
`+c}function i(n,e){let t=e.author.name?`// Made with \u2764\uFE0F by ${e.author.name}.`:"// Made with \u2764\uFE0F by Maysara.";return`// ${n}
|
|
14
|
+
//
|
|
15
|
+
${t}
|
|
16
|
+
`}function f(n,e){let t=i("src/index.ts",e)+s("PACK",n==="cli"?`import { cli } from '@langpkg/cli';
|
|
17
|
+
`:"");if(n==="pkg")t+=s("MAIN",`export const add = (a: number, b: number): number => a + b;
|
|
18
|
+
`);else{let r=`export const run = (): void => {
|
|
19
|
+
console.log('${e.name} running...');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
run();
|
|
23
|
+
`;t+=s("MAIN",r)}let o=_mcs_fmt.formatTS.call(void 0, t,"src/index.ts");if(_optionalChain([o, 'access', _7 => _7.errors, 'optionalAccess', _8 => _8.length]))throw console.error("Error formatting src/index.ts:",JSON.stringify(o.errors,null,2)),new Error("Failed to generate src/index.ts due to formatting errors.");return o.formatted+`
|
|
24
|
+
`}function d(n,e){let t={curly:"off","@stylistic/semi":["warn","always"],"@typescript-eslint/no-empty-function":"off","@typescript-eslint/naming-convention":["warn",{selector:"variable",format:["snake_case","camelCase"],filter:{match:!1,regex:"^_"}},{selector:"function",format:["camelCase"]},{selector:"method",format:["camelCase"]},{selector:"typeLike",format:["PascalCase"]},{selector:"import",format:["camelCase","PascalCase"]},{selector:"variable",modifiers:["const"],format:["UPPER_CASE","snake_case","camelCase"],filter:{match:!1,regex:"^_"}},{selector:"enumMember",format:["PascalCase"]}],"@typescript-eslint/no-unused-vars":["error",{argsIgnorePattern:"^_"}]},o=i("eslint.config.ts",e)+s("PACK",`import { defineConfig } from 'eslint/config';
|
|
25
|
+
import js from '@eslint/js';
|
|
26
|
+
import tseslint from 'typescript-eslint';
|
|
27
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
28
|
+
`)+s("CONST",`const rules = ${_mcs_fmt.formatJSON.call(void 0, JSON.stringify(t)).formatted}`)+s("CONF",`export default defineConfig(
|
|
29
|
+
|
|
30
|
+
js.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic,
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
ignores : ['**/.vscode-test', '**/out', 'dist/', 'node_modules/', '.git/'],
|
|
34
|
+
plugins : { '@stylistic': stylistic },
|
|
35
|
+
rules : rules
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
`),r=_mcs_fmt.formatTS.call(void 0, o,"eslint.config.ts");if(_optionalChain([r, 'access', _9 => _9.errors, 'optionalAccess', _10 => _10.length]))throw console.error("Error formatting eslint.config.ts:",JSON.stringify(r.errors,null,2)),new Error("Failed to generate eslint.config.ts due to formatting errors.");return r.formatted+`
|
|
39
|
+
`}function y(n,e){let t=n==="pkg"?`describe('${e.name}', () => {
|
|
40
|
+
it('should add two numbers correctly', () => {
|
|
41
|
+
expect(add(1, 1)).toBe(2);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
`:`describe('CLI', () => {
|
|
45
|
+
it('should run without errors', () => {
|
|
46
|
+
expect(() => run()).not.toThrow();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
`,o=i("test/index.test.ts",e)+s("PACK",`import { describe, it, expect } from 'bun:test';
|
|
50
|
+
`+(n==="pkg"?`import { add } from '../src';
|
|
51
|
+
`:""))+s("TEST",t),r=_mcs_fmt.formatTS.call(void 0, o,"test/index.test.ts");if(_optionalChain([r, 'access', _11 => _11.errors, 'optionalAccess', _12 => _12.length]))throw console.error("Error formatting test/index.test.ts:",JSON.stringify(r.errors,null,2)),new Error("Failed to generate test/index.test.ts due to formatting errors.");return r.formatted+`
|
|
52
|
+
`}function b(n,e){let t={entry:["src/index.ts"],format:["esm","cjs"],dts:!0,minify:!0,sourcemap:!1,clean:!0,splitting:!0};n==="cli"&&(t.banner={js:"#!/usr/bin/env bun"});let o=i("tsup.config.ts",e)+s("PACK",`import { defineConfig } from 'tsup';
|
|
53
|
+
`)+s("CONST",`const rules = ${_mcs_fmt.formatJSON.call(void 0, JSON.stringify(t)).formatted}`)+s("CONF",`// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
export default defineConfig(rules as any);
|
|
55
|
+
`),r=_mcs_fmt.formatTS.call(void 0, o,"tsup.config.ts");if(_optionalChain([r, 'access', _13 => _13.errors, 'optionalAccess', _14 => _14.length]))throw console.error("Error formatting tsup.config.ts:",JSON.stringify(r.errors,null,2)),new Error("Failed to generate tsup.config.ts due to formatting errors.");return r.formatted+`
|
|
56
|
+
`}function h(){return`# Dependencies
|
|
57
|
+
node_modules/
|
|
58
|
+
package-lock.json
|
|
59
|
+
yarn.lock
|
|
60
|
+
pnpm-lock.yaml
|
|
61
|
+
bun.lockb
|
|
62
|
+
|
|
63
|
+
# Build outputs
|
|
64
|
+
dist/
|
|
65
|
+
build/
|
|
66
|
+
*.tsbuildinfo
|
|
67
|
+
|
|
68
|
+
# Environment variables
|
|
69
|
+
.env
|
|
70
|
+
.env.local
|
|
71
|
+
.env.*.local
|
|
72
|
+
|
|
73
|
+
# PKG
|
|
74
|
+
.pkg/
|
|
75
|
+
# IDE
|
|
76
|
+
.vscode/
|
|
77
|
+
.idea/
|
|
78
|
+
*.swp
|
|
79
|
+
*.swo
|
|
80
|
+
|
|
81
|
+
# OS
|
|
82
|
+
.DS_Store
|
|
83
|
+
Thumbs.db
|
|
84
|
+
|
|
85
|
+
# Test coverage
|
|
86
|
+
coverage/
|
|
87
|
+
.nyc_output/
|
|
88
|
+
`}function v(n){let e=n.author.name||"",t=n.author.email||"",o=typeof n.author.github=="string"?n.author.github.trim():"",r=o?o.includes("github.com")?o:`https://github.com/${o.replace(/^@/,"")}`:"";return e?r?`${e} (${r})`:t?`${e} (${t})`:e:""}function A(n){let e=new Date().getFullYear(),t=v(n);return`Copyright (c) ${e}${t?" "+t:""}`}function x(n){return`MIT License
|
|
89
|
+
|
|
90
|
+
${A(n)}
|
|
91
|
+
|
|
92
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
93
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
94
|
+
in the Software without restriction, including without limitation the rights
|
|
95
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
96
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
97
|
+
furnished to do so, subject to the following conditions:
|
|
98
|
+
|
|
99
|
+
The above copyright notice and this permission notice shall be included in all
|
|
100
|
+
copies or substantial portions of the Software.
|
|
101
|
+
|
|
102
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
103
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
104
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
105
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
106
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
107
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
108
|
+
SOFTWARE.
|
|
109
|
+
`}function E(){return`# Source and test files
|
|
110
|
+
src/
|
|
111
|
+
test/
|
|
112
|
+
*.test.ts
|
|
113
|
+
*.tsbuildinfo
|
|
114
|
+
|
|
115
|
+
# Build and package artifacts
|
|
116
|
+
.pkg/
|
|
117
|
+
assets/
|
|
118
|
+
|
|
119
|
+
# Configuration files
|
|
120
|
+
tsconfig.json
|
|
121
|
+
eslint.config.mjs
|
|
122
|
+
tsup.config.ts
|
|
123
|
+
vitest.config.ts
|
|
124
|
+
jest.config.js
|
|
125
|
+
|
|
126
|
+
# Documentation (keep README only)
|
|
127
|
+
docs/
|
|
128
|
+
CHANGELOG.md
|
|
129
|
+
CONTRIBUTING.md
|
|
130
|
+
|
|
131
|
+
# Development files
|
|
132
|
+
.vscode/
|
|
133
|
+
.idea/
|
|
134
|
+
.env
|
|
135
|
+
.env.local
|
|
136
|
+
.DS_Store
|
|
137
|
+
Thumbs.db
|
|
138
|
+
|
|
139
|
+
# Git and version control
|
|
140
|
+
.git/
|
|
141
|
+
.gitignore
|
|
142
|
+
.gitattributes
|
|
143
|
+
|
|
144
|
+
# Package manager lock files
|
|
145
|
+
package-lock.json
|
|
146
|
+
yarn.lock
|
|
147
|
+
pnpm-lock.yaml
|
|
148
|
+
bun.lockb
|
|
149
|
+
|
|
150
|
+
# IDE and editor files
|
|
151
|
+
*.swp
|
|
152
|
+
*.swo
|
|
153
|
+
*~
|
|
154
|
+
`}function T(n,e){let t=n==="cli"?L(e):$(e),o=_mcs_fmt.formatMD.call(void 0, t,"README.md");if(_optionalChain([o, 'access', _15 => _15.errors, 'optionalAccess', _16 => _16.length]))throw console.error("Error formatting readme:",JSON.stringify(o.errors,null,2)),new Error("Failed to generate readme due to formatting errors.");return o.formatted+`
|
|
155
|
+
`}function L(n){return`# ${n.name}
|
|
156
|
+
|
|
157
|
+
${n.description||"A TypeScript command-line tool."}
|
|
158
|
+
|
|
159
|
+
## Installation
|
|
160
|
+
|
|
161
|
+
\`\`\`bash
|
|
162
|
+
pkg install -g ${n.name}
|
|
163
|
+
\`\`\`
|
|
164
|
+
|
|
165
|
+
## Usage
|
|
166
|
+
|
|
167
|
+
\`\`\`bash
|
|
168
|
+
${n.name} --help
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
\`\`\`bash
|
|
174
|
+
pkg install
|
|
175
|
+
pkg dev # Build in watch mode (TODO)
|
|
176
|
+
pkg lint # Lint code
|
|
177
|
+
pkg build # Build for production
|
|
178
|
+
\`\`\`
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
${n.license}`+(n.author.name?` \xA9 ${new Date().getFullYear()} ${n.author.name}`:"")+`
|
|
183
|
+
`}function $(n){return`# ${n.name}
|
|
184
|
+
|
|
185
|
+
${n.description||"A TypeScript library."}
|
|
186
|
+
|
|
187
|
+
## Installation
|
|
188
|
+
|
|
189
|
+
\`\`\`bash
|
|
190
|
+
pkg install ${n.name}
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
## Usage
|
|
194
|
+
|
|
195
|
+
\`\`\`typescript
|
|
196
|
+
import { example } from '${n.name}'
|
|
197
|
+
|
|
198
|
+
example()
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
\`\`\`bash
|
|
204
|
+
pkg install
|
|
205
|
+
pkg build # Build distribution files
|
|
206
|
+
pkg lint # Lint code
|
|
207
|
+
pkg test # Run tests
|
|
208
|
+
\`\`\`
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
${n.license}`+(n.author.name?` \xA9 ${new Date().getFullYear()} ${n.author.name}`:"")+`
|
|
213
|
+
`}var S=class extends Error{constructor(t,o,r){super(t);this.code=o;this.ctx=r;this.name="PkgError"}};function Fe(n,e,t){switch(n){case"package.json":return u(e,t);case"tsconfig.json":return p(e);case".vscode/settings.json":return m();case"tsup.config.ts":return b(e,t);case"eslint.config.mjs":return d(e,t);case"src/index.ts":return f(e,t);case"test/index.test.ts":return y(e,t);case"README.md":return T(e,t);case".gitignore":return h();case".npmignore":return E();case"LICENSE":return x(t);default:throw new Error(`Unknown file: ${n}`)}}exports.PkgError = S; exports.generateEslintConfig = d; exports.generateFile = Fe; exports.generateGitignore = h; exports.generateLicense = x; exports.generateNpmignore = E; exports.generatePackageJson = u; exports.generateReadme = T; exports.generateSourceIndexTs = f; exports.generateTestIndexTs = y; exports.generateTsconfig = p; exports.generateTsupConfig = b; exports.generateVscodeSettings = m;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
type ProjectType = 'pkg' | 'cli';
|
|
2
|
+
interface ProjectMeta {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
description: string;
|
|
6
|
+
license: string;
|
|
7
|
+
author: {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
github: string;
|
|
11
|
+
};
|
|
12
|
+
org: string;
|
|
13
|
+
repoName: string;
|
|
14
|
+
}
|
|
15
|
+
interface FormatResult {
|
|
16
|
+
formatted: string;
|
|
17
|
+
count: number;
|
|
18
|
+
errors?: FormatError[];
|
|
19
|
+
}
|
|
20
|
+
interface FormatError {
|
|
21
|
+
message: string;
|
|
22
|
+
line?: number;
|
|
23
|
+
column?: number;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
type IssueSeverity = 'error' | 'warning';
|
|
27
|
+
type FormatFix = {
|
|
28
|
+
type: 'reformat';
|
|
29
|
+
content: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'replace_line';
|
|
32
|
+
line: number;
|
|
33
|
+
content: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'insert_after_line';
|
|
36
|
+
line: number;
|
|
37
|
+
content: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'insert_before_line';
|
|
40
|
+
line: number;
|
|
41
|
+
content: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'remove_blank_lines';
|
|
44
|
+
line: number;
|
|
45
|
+
count: number;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'append_lines';
|
|
48
|
+
content: string;
|
|
49
|
+
};
|
|
50
|
+
interface FormatIssue {
|
|
51
|
+
file: string;
|
|
52
|
+
line: number;
|
|
53
|
+
code: string;
|
|
54
|
+
message: string;
|
|
55
|
+
severity: IssueSeverity;
|
|
56
|
+
fixable: boolean;
|
|
57
|
+
fix?: FormatFix;
|
|
58
|
+
}
|
|
59
|
+
declare class PkgError extends Error {
|
|
60
|
+
code: string;
|
|
61
|
+
ctx?: Record<string, unknown> | undefined;
|
|
62
|
+
constructor(msg: string, code: string, ctx?: Record<string, unknown> | undefined);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare function generateSourceIndexTs(projectType: ProjectType, meta: ProjectMeta): string;
|
|
66
|
+
|
|
67
|
+
declare function generateEslintConfig(projectType: ProjectType, meta: ProjectMeta): string;
|
|
68
|
+
|
|
69
|
+
declare function generateTestIndexTs(projectType: ProjectType, meta: ProjectMeta): string;
|
|
70
|
+
|
|
71
|
+
declare function generateTsupConfig(projectType: ProjectType, meta: ProjectMeta): string;
|
|
72
|
+
|
|
73
|
+
declare function generateReadme(projectType: ProjectType, meta: ProjectMeta): string;
|
|
74
|
+
|
|
75
|
+
declare function generateVscodeSettings(): string;
|
|
76
|
+
|
|
77
|
+
declare function generatePackageJson(projectType: ProjectType, meta: ProjectMeta): string;
|
|
78
|
+
|
|
79
|
+
declare function generateTsconfig(projectType: ProjectType): string;
|
|
80
|
+
|
|
81
|
+
declare function generateGitignore(): string;
|
|
82
|
+
|
|
83
|
+
declare function generateLicense(meta: ProjectMeta): string;
|
|
84
|
+
|
|
85
|
+
declare function generateNpmignore(): string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Main entry point for file generation
|
|
89
|
+
* Routes filename to the appropriate generator function
|
|
90
|
+
*/
|
|
91
|
+
declare function generateFile(filename: string, projectType: ProjectType, meta: ProjectMeta): string;
|
|
92
|
+
|
|
93
|
+
export { type FormatError, type FormatFix, type FormatIssue, type FormatResult, type IssueSeverity, PkgError, type ProjectMeta, type ProjectType, generateEslintConfig, generateFile, generateGitignore, generateLicense, generateNpmignore, generatePackageJson, generateReadme, generateSourceIndexTs, generateTestIndexTs, generateTsconfig, generateTsupConfig, generateVscodeSettings };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
type ProjectType = 'pkg' | 'cli';
|
|
2
|
+
interface ProjectMeta {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
description: string;
|
|
6
|
+
license: string;
|
|
7
|
+
author: {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
github: string;
|
|
11
|
+
};
|
|
12
|
+
org: string;
|
|
13
|
+
repoName: string;
|
|
14
|
+
}
|
|
15
|
+
interface FormatResult {
|
|
16
|
+
formatted: string;
|
|
17
|
+
count: number;
|
|
18
|
+
errors?: FormatError[];
|
|
19
|
+
}
|
|
20
|
+
interface FormatError {
|
|
21
|
+
message: string;
|
|
22
|
+
line?: number;
|
|
23
|
+
column?: number;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
type IssueSeverity = 'error' | 'warning';
|
|
27
|
+
type FormatFix = {
|
|
28
|
+
type: 'reformat';
|
|
29
|
+
content: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'replace_line';
|
|
32
|
+
line: number;
|
|
33
|
+
content: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'insert_after_line';
|
|
36
|
+
line: number;
|
|
37
|
+
content: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'insert_before_line';
|
|
40
|
+
line: number;
|
|
41
|
+
content: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'remove_blank_lines';
|
|
44
|
+
line: number;
|
|
45
|
+
count: number;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'append_lines';
|
|
48
|
+
content: string;
|
|
49
|
+
};
|
|
50
|
+
interface FormatIssue {
|
|
51
|
+
file: string;
|
|
52
|
+
line: number;
|
|
53
|
+
code: string;
|
|
54
|
+
message: string;
|
|
55
|
+
severity: IssueSeverity;
|
|
56
|
+
fixable: boolean;
|
|
57
|
+
fix?: FormatFix;
|
|
58
|
+
}
|
|
59
|
+
declare class PkgError extends Error {
|
|
60
|
+
code: string;
|
|
61
|
+
ctx?: Record<string, unknown> | undefined;
|
|
62
|
+
constructor(msg: string, code: string, ctx?: Record<string, unknown> | undefined);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare function generateSourceIndexTs(projectType: ProjectType, meta: ProjectMeta): string;
|
|
66
|
+
|
|
67
|
+
declare function generateEslintConfig(projectType: ProjectType, meta: ProjectMeta): string;
|
|
68
|
+
|
|
69
|
+
declare function generateTestIndexTs(projectType: ProjectType, meta: ProjectMeta): string;
|
|
70
|
+
|
|
71
|
+
declare function generateTsupConfig(projectType: ProjectType, meta: ProjectMeta): string;
|
|
72
|
+
|
|
73
|
+
declare function generateReadme(projectType: ProjectType, meta: ProjectMeta): string;
|
|
74
|
+
|
|
75
|
+
declare function generateVscodeSettings(): string;
|
|
76
|
+
|
|
77
|
+
declare function generatePackageJson(projectType: ProjectType, meta: ProjectMeta): string;
|
|
78
|
+
|
|
79
|
+
declare function generateTsconfig(projectType: ProjectType): string;
|
|
80
|
+
|
|
81
|
+
declare function generateGitignore(): string;
|
|
82
|
+
|
|
83
|
+
declare function generateLicense(meta: ProjectMeta): string;
|
|
84
|
+
|
|
85
|
+
declare function generateNpmignore(): string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Main entry point for file generation
|
|
89
|
+
* Routes filename to the appropriate generator function
|
|
90
|
+
*/
|
|
91
|
+
declare function generateFile(filename: string, projectType: ProjectType, meta: ProjectMeta): string;
|
|
92
|
+
|
|
93
|
+
export { type FormatError, type FormatFix, type FormatIssue, type FormatResult, type IssueSeverity, PkgError, type ProjectMeta, type ProjectType, generateEslintConfig, generateFile, generateGitignore, generateLicense, generateNpmignore, generatePackageJson, generateReadme, generateSourceIndexTs, generateTestIndexTs, generateTsconfig, generateTsupConfig, generateVscodeSettings };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import{formatJSON as O}from"@langpkg/mcs_fmt";function m(){let e=O(JSON.stringify({"files.exclude":{"**/.git":!0,"**/.svn":!0,"**/.hg":!0,"**/.DS_Store":!0,"**/Thumbs.db":!0,"eslint.config.mjs":!0,"bun.lock":!0,"package-lock.json":!0,LICENSE:!0,".gitignore":!0,".gitattributes":!0,".npmignore":!0,node_modules:!0,"tsup.config.ts":!0,"tsconfig.json":!0},"hide-files.files":["eslint.config.mjs",".pkg",".vscode","bun.lock","package-lock.json","LICENSE",".gitignore",".gitattributes",".npmignore","node_modules","tsup.config.ts","tsconfig.json"]}),".vscode/settings.json");if(e.errors?.length)throw console.error("Error formatting vscode settings:",JSON.stringify(e.errors,null,2)),new Error("Failed to generate vscode settings due to formatting errors.");return e.formatted+`
|
|
2
|
+
`}import{formatJSON as N}from"@langpkg/mcs_fmt";function u(n,e){let t=e.org&&e.repoName?`https://github.com/${e.org}/${e.repoName}`:"",o=[e.author.name,e.author.email?`<${e.author.email}>`:""].filter(Boolean).join(" "),r={name:e.name,version:e.version,description:e.description,keywords:[],license:e.license,author:o||"",repository:t?{type:"git",url:`git+${t}.git`}:"",type:"module",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},scripts:{},dependencies:{},devDependencies:{"@eslint/js":"^9.39.4","@stylistic/eslint-plugin":"^5.10.0","@types/bun":"^1.3.13","@types/node":"^25.7.0","bun-plugin-dts":"^0.3.0","bun-types":"^1.3.13","ts-node":"^10.9.2",tsup:"^8.5.1",typescript:"^5.9.3","typescript-eslint":"^8.59.3"}};if(n==="cli"){let a=e.name.replace(/^@[^/]+\//,""),g={};for(let[l,j]of Object.entries(r))g[l]=j,l==="type"&&(g.bin={[a]:"./dist/index.js"},g.pkg={type:"cli"});Object.keys(r).forEach(l=>delete r[l]),Object.assign(r,g)}else r.pkg={type:"lib"};let c=N(JSON.stringify(r),"package.json");if(c.errors?.length)throw console.error("Error formatting package.json:",JSON.stringify(c.errors,null,2)),new Error("Failed to generate package.json due to formatting errors.");return c.formatted+`
|
|
3
|
+
`}import{formatJSON as k}from"@langpkg/mcs_fmt";function p(n){let t=k(JSON.stringify({compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",lib:["DOM","ES2020","ESNext"],types:["node"],declaration:n==="pkg",outDir:"./dist",strict:!0,esModuleInterop:!0,skipLibCheck:!0,forceConsistentCasingInFileNames:!0,resolveJsonModule:!0,isolatedModules:!0,allowImportingTsExtensions:!0,noEmit:!0,ignoreDeprecations:"6.0"},include:["src","test"],exclude:["node_modules","dist"]}),"tsconfig.json");if(t.errors?.length)throw console.error("Error formatting tsconfig.json:",JSON.stringify(t.errors,null,2)),new Error("Failed to generate tsconfig.json due to formatting errors.");return t.formatted+`
|
|
4
|
+
`}import{formatTS as P}from"@langpkg/mcs_fmt";function s(n,e,t=!0){let o=t?`
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
`:"",r="// \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 "+n+` \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
8
|
+
|
|
9
|
+
`,c=`// \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
10
|
+
`;return e=e.split(`
|
|
11
|
+
`).map(a=>a===""?a:" "+a).join(`
|
|
12
|
+
`),o+r+e+`
|
|
13
|
+
`+c}function i(n,e){let t=e.author.name?`// Made with \u2764\uFE0F by ${e.author.name}.`:"// Made with \u2764\uFE0F by Maysara.";return`// ${n}
|
|
14
|
+
//
|
|
15
|
+
${t}
|
|
16
|
+
`}function f(n,e){let t=i("src/index.ts",e)+s("PACK",n==="cli"?`import { cli } from '@langpkg/cli';
|
|
17
|
+
`:"");if(n==="pkg")t+=s("MAIN",`export const add = (a: number, b: number): number => a + b;
|
|
18
|
+
`);else{let r=`export const run = (): void => {
|
|
19
|
+
console.log('${e.name} running...');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
run();
|
|
23
|
+
`;t+=s("MAIN",r)}let o=P(t,"src/index.ts");if(o.errors?.length)throw console.error("Error formatting src/index.ts:",JSON.stringify(o.errors,null,2)),new Error("Failed to generate src/index.ts due to formatting errors.");return o.formatted+`
|
|
24
|
+
`}import{formatTS as I,formatJSON as w}from"@langpkg/mcs_fmt";function d(n,e){let t={curly:"off","@stylistic/semi":["warn","always"],"@typescript-eslint/no-empty-function":"off","@typescript-eslint/naming-convention":["warn",{selector:"variable",format:["snake_case","camelCase"],filter:{match:!1,regex:"^_"}},{selector:"function",format:["camelCase"]},{selector:"method",format:["camelCase"]},{selector:"typeLike",format:["PascalCase"]},{selector:"import",format:["camelCase","PascalCase"]},{selector:"variable",modifiers:["const"],format:["UPPER_CASE","snake_case","camelCase"],filter:{match:!1,regex:"^_"}},{selector:"enumMember",format:["PascalCase"]}],"@typescript-eslint/no-unused-vars":["error",{argsIgnorePattern:"^_"}]},o=i("eslint.config.ts",e)+s("PACK",`import { defineConfig } from 'eslint/config';
|
|
25
|
+
import js from '@eslint/js';
|
|
26
|
+
import tseslint from 'typescript-eslint';
|
|
27
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
28
|
+
`)+s("CONST",`const rules = ${w(JSON.stringify(t)).formatted}`)+s("CONF",`export default defineConfig(
|
|
29
|
+
|
|
30
|
+
js.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic,
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
ignores : ['**/.vscode-test', '**/out', 'dist/', 'node_modules/', '.git/'],
|
|
34
|
+
plugins : { '@stylistic': stylistic },
|
|
35
|
+
rules : rules
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
`),r=I(o,"eslint.config.ts");if(r.errors?.length)throw console.error("Error formatting eslint.config.ts:",JSON.stringify(r.errors,null,2)),new Error("Failed to generate eslint.config.ts due to formatting errors.");return r.formatted+`
|
|
39
|
+
`}import{formatTS as C}from"@langpkg/mcs_fmt";function y(n,e){let t=n==="pkg"?`describe('${e.name}', () => {
|
|
40
|
+
it('should add two numbers correctly', () => {
|
|
41
|
+
expect(add(1, 1)).toBe(2);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
`:`describe('CLI', () => {
|
|
45
|
+
it('should run without errors', () => {
|
|
46
|
+
expect(() => run()).not.toThrow();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
`,o=i("test/index.test.ts",e)+s("PACK",`import { describe, it, expect } from 'bun:test';
|
|
50
|
+
`+(n==="pkg"?`import { add } from '../src';
|
|
51
|
+
`:""))+s("TEST",t),r=C(o,"test/index.test.ts");if(r.errors?.length)throw console.error("Error formatting test/index.test.ts:",JSON.stringify(r.errors,null,2)),new Error("Failed to generate test/index.test.ts due to formatting errors.");return r.formatted+`
|
|
52
|
+
`}import{formatJSON as R,formatTS as M}from"@langpkg/mcs_fmt";function b(n,e){let t={entry:["src/index.ts"],format:["esm","cjs"],dts:!0,minify:!0,sourcemap:!1,clean:!0,splitting:!0};n==="cli"&&(t.banner={js:"#!/usr/bin/env bun"});let o=i("tsup.config.ts",e)+s("PACK",`import { defineConfig } from 'tsup';
|
|
53
|
+
`)+s("CONST",`const rules = ${R(JSON.stringify(t)).formatted}`)+s("CONF",`// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
export default defineConfig(rules as any);
|
|
55
|
+
`),r=M(o,"tsup.config.ts");if(r.errors?.length)throw console.error("Error formatting tsup.config.ts:",JSON.stringify(r.errors,null,2)),new Error("Failed to generate tsup.config.ts due to formatting errors.");return r.formatted+`
|
|
56
|
+
`}function h(){return`# Dependencies
|
|
57
|
+
node_modules/
|
|
58
|
+
package-lock.json
|
|
59
|
+
yarn.lock
|
|
60
|
+
pnpm-lock.yaml
|
|
61
|
+
bun.lockb
|
|
62
|
+
|
|
63
|
+
# Build outputs
|
|
64
|
+
dist/
|
|
65
|
+
build/
|
|
66
|
+
*.tsbuildinfo
|
|
67
|
+
|
|
68
|
+
# Environment variables
|
|
69
|
+
.env
|
|
70
|
+
.env.local
|
|
71
|
+
.env.*.local
|
|
72
|
+
|
|
73
|
+
# PKG
|
|
74
|
+
.pkg/
|
|
75
|
+
# IDE
|
|
76
|
+
.vscode/
|
|
77
|
+
.idea/
|
|
78
|
+
*.swp
|
|
79
|
+
*.swo
|
|
80
|
+
|
|
81
|
+
# OS
|
|
82
|
+
.DS_Store
|
|
83
|
+
Thumbs.db
|
|
84
|
+
|
|
85
|
+
# Test coverage
|
|
86
|
+
coverage/
|
|
87
|
+
.nyc_output/
|
|
88
|
+
`}function v(n){let e=n.author.name||"",t=n.author.email||"",o=typeof n.author.github=="string"?n.author.github.trim():"",r=o?o.includes("github.com")?o:`https://github.com/${o.replace(/^@/,"")}`:"";return e?r?`${e} (${r})`:t?`${e} (${t})`:e:""}function A(n){let e=new Date().getFullYear(),t=v(n);return`Copyright (c) ${e}${t?" "+t:""}`}function x(n){return`MIT License
|
|
89
|
+
|
|
90
|
+
${A(n)}
|
|
91
|
+
|
|
92
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
93
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
94
|
+
in the Software without restriction, including without limitation the rights
|
|
95
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
96
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
97
|
+
furnished to do so, subject to the following conditions:
|
|
98
|
+
|
|
99
|
+
The above copyright notice and this permission notice shall be included in all
|
|
100
|
+
copies or substantial portions of the Software.
|
|
101
|
+
|
|
102
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
103
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
104
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
105
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
106
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
107
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
108
|
+
SOFTWARE.
|
|
109
|
+
`}function E(){return`# Source and test files
|
|
110
|
+
src/
|
|
111
|
+
test/
|
|
112
|
+
*.test.ts
|
|
113
|
+
*.tsbuildinfo
|
|
114
|
+
|
|
115
|
+
# Build and package artifacts
|
|
116
|
+
.pkg/
|
|
117
|
+
assets/
|
|
118
|
+
|
|
119
|
+
# Configuration files
|
|
120
|
+
tsconfig.json
|
|
121
|
+
eslint.config.mjs
|
|
122
|
+
tsup.config.ts
|
|
123
|
+
vitest.config.ts
|
|
124
|
+
jest.config.js
|
|
125
|
+
|
|
126
|
+
# Documentation (keep README only)
|
|
127
|
+
docs/
|
|
128
|
+
CHANGELOG.md
|
|
129
|
+
CONTRIBUTING.md
|
|
130
|
+
|
|
131
|
+
# Development files
|
|
132
|
+
.vscode/
|
|
133
|
+
.idea/
|
|
134
|
+
.env
|
|
135
|
+
.env.local
|
|
136
|
+
.DS_Store
|
|
137
|
+
Thumbs.db
|
|
138
|
+
|
|
139
|
+
# Git and version control
|
|
140
|
+
.git/
|
|
141
|
+
.gitignore
|
|
142
|
+
.gitattributes
|
|
143
|
+
|
|
144
|
+
# Package manager lock files
|
|
145
|
+
package-lock.json
|
|
146
|
+
yarn.lock
|
|
147
|
+
pnpm-lock.yaml
|
|
148
|
+
bun.lockb
|
|
149
|
+
|
|
150
|
+
# IDE and editor files
|
|
151
|
+
*.swp
|
|
152
|
+
*.swo
|
|
153
|
+
*~
|
|
154
|
+
`}import{formatMD as F}from"@langpkg/mcs_fmt";function T(n,e){let t=n==="cli"?L(e):$(e),o=F(t,"README.md");if(o.errors?.length)throw console.error("Error formatting readme:",JSON.stringify(o.errors,null,2)),new Error("Failed to generate readme due to formatting errors.");return o.formatted+`
|
|
155
|
+
`}function L(n){return`# ${n.name}
|
|
156
|
+
|
|
157
|
+
${n.description||"A TypeScript command-line tool."}
|
|
158
|
+
|
|
159
|
+
## Installation
|
|
160
|
+
|
|
161
|
+
\`\`\`bash
|
|
162
|
+
pkg install -g ${n.name}
|
|
163
|
+
\`\`\`
|
|
164
|
+
|
|
165
|
+
## Usage
|
|
166
|
+
|
|
167
|
+
\`\`\`bash
|
|
168
|
+
${n.name} --help
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
\`\`\`bash
|
|
174
|
+
pkg install
|
|
175
|
+
pkg dev # Build in watch mode (TODO)
|
|
176
|
+
pkg lint # Lint code
|
|
177
|
+
pkg build # Build for production
|
|
178
|
+
\`\`\`
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
${n.license}`+(n.author.name?` \xA9 ${new Date().getFullYear()} ${n.author.name}`:"")+`
|
|
183
|
+
`}function $(n){return`# ${n.name}
|
|
184
|
+
|
|
185
|
+
${n.description||"A TypeScript library."}
|
|
186
|
+
|
|
187
|
+
## Installation
|
|
188
|
+
|
|
189
|
+
\`\`\`bash
|
|
190
|
+
pkg install ${n.name}
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
## Usage
|
|
194
|
+
|
|
195
|
+
\`\`\`typescript
|
|
196
|
+
import { example } from '${n.name}'
|
|
197
|
+
|
|
198
|
+
example()
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
\`\`\`bash
|
|
204
|
+
pkg install
|
|
205
|
+
pkg build # Build distribution files
|
|
206
|
+
pkg lint # Lint code
|
|
207
|
+
pkg test # Run tests
|
|
208
|
+
\`\`\`
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
${n.license}`+(n.author.name?` \xA9 ${new Date().getFullYear()} ${n.author.name}`:"")+`
|
|
213
|
+
`}var S=class extends Error{constructor(t,o,r){super(t);this.code=o;this.ctx=r;this.name="PkgError"}};function Fe(n,e,t){switch(n){case"package.json":return u(e,t);case"tsconfig.json":return p(e);case".vscode/settings.json":return m();case"tsup.config.ts":return b(e,t);case"eslint.config.mjs":return d(e,t);case"src/index.ts":return f(e,t);case"test/index.test.ts":return y(e,t);case"README.md":return T(e,t);case".gitignore":return h();case".npmignore":return E();case"LICENSE":return x(t);default:throw new Error(`Unknown file: ${n}`)}}export{S as PkgError,d as generateEslintConfig,Fe as generateFile,h as generateGitignore,x as generateLicense,E as generateNpmignore,u as generatePackageJson,T as generateReadme,f as generateSourceIndexTs,y as generateTestIndexTs,p as generateTsconfig,b as generateTsupConfig,m as generateVscodeSettings};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langpkg/mcs_gen",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "maysara code style generator",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@langpkg/mcs_fmt": "^0.0.
|
|
27
|
+
"@langpkg/mcs_fmt": "^0.0.3",
|
|
28
28
|
"glob": "^13.0.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/assets/img/line.png
DELETED
|
Binary file
|
package/assets/img/logo.png
DELETED
|
Binary file
|
package/docs/.gitkeep
DELETED
|
File without changes
|