@langpkg/mcs_gen 0.0.3 → 0.0.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.
- package/README.md +1 -1
- package/dist/index.cjs +36 -36
- package/dist/index.js +36 -36
- package/package.json +6 -5
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.4-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
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
`}function u(
|
|
3
|
-
`}function p(
|
|
4
|
-
`}function s(
|
|
1
|
+
'use strict';var mcs_fmt=require('@langpkg/mcs_fmt');function m(){let e=mcs_fmt.formatJSON(JSON.stringify({"files.exclude":{"**/.git":true,"**/.svn":true,"**/.hg":true,"**/.DS_Store":true,"**/Thumbs.db":true,"eslint.config.mjs":true,"bun.lock":true,"package-lock.json":true,LICENSE:true,".gitignore":true,".gitattributes":true,".npmignore":true,node_modules:true,"tsup.config.ts":true,"tsconfig.json":true},"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
|
+
`}function u(t,e){let n=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:n?{type:"git",url:`git+${n}.git`}:"",type:"module",files:["dist"],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(t==="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(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
|
+
`}function p(t){let n=mcs_fmt.formatJSON(JSON.stringify({compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",lib:["DOM","ES2020","ESNext"],types:["node"],declaration:t==="pkg",outDir:"./dist",strict:true,esModuleInterop:true,skipLibCheck:true,forceConsistentCasingInFileNames:true,resolveJsonModule:true,isolatedModules:true,allowImportingTsExtensions:true,noEmit:true,ignoreDeprecations:"6.0"},include:["src","test"],exclude:["node_modules","dist"]}),"tsconfig.json");if(n.errors?.length)throw console.error("Error formatting tsconfig.json:",JSON.stringify(n.errors,null,2)),new Error("Failed to generate tsconfig.json due to formatting errors.");return n.formatted+`
|
|
4
|
+
`}function s(t,e,n=true){let o=n?`
|
|
5
5
|
|
|
6
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 "+
|
|
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 "+t+` \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
8
|
|
|
9
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
10
|
`;return e=e.split(`
|
|
11
11
|
`).map(a=>a===""?a:" "+a).join(`
|
|
12
12
|
`),o+r+e+`
|
|
13
|
-
`+c}function i(
|
|
13
|
+
`+c}function i(t,e){let n=e.author.name?`// Made with \u2764\uFE0F by ${e.author.name}.`:"// Made with \u2764\uFE0F by Maysara.";return `// ${t}
|
|
14
14
|
//
|
|
15
|
-
${
|
|
16
|
-
`}function f(
|
|
17
|
-
`:"");if(
|
|
18
|
-
`);else{let r=`export const run = (): void => {
|
|
15
|
+
${n}
|
|
16
|
+
`}function f(t,e){let n=i("src/index.ts",e)+s("PACK",t==="cli"?`import { cli } from '@langpkg/cli';
|
|
17
|
+
`:"");if(t==="pkg")n+=s("MAIN",`export const add = (a: number, b: number): number => a + b;
|
|
18
|
+
`);else {let r=`export const run = (): void => {
|
|
19
19
|
console.log('${e.name} running...');
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
run();
|
|
23
|
-
`;
|
|
24
|
-
`}function d(
|
|
23
|
+
`;n+=s("MAIN",r);}let o=mcs_fmt.formatTS(n,"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
|
+
`}function d(t,e){let n={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:false,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:false,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
25
|
import js from '@eslint/js';
|
|
26
26
|
import tseslint from 'typescript-eslint';
|
|
27
27
|
import stylistic from '@stylistic/eslint-plugin';
|
|
28
|
-
`)+s("CONST",`const rules = ${
|
|
28
|
+
`)+s("CONST",`const rules = ${mcs_fmt.formatJSON(JSON.stringify(n)).formatted}`)+s("CONF",`export default defineConfig(
|
|
29
29
|
|
|
30
30
|
js.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic,
|
|
31
31
|
|
|
@@ -35,8 +35,8 @@ import stylistic from '@stylistic/eslint-plugin';
|
|
|
35
35
|
rules : rules
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
|
-
`),r=
|
|
39
|
-
`}function y(
|
|
38
|
+
`),r=mcs_fmt.formatTS(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
|
+
`}function y(t,e){let n=t==="pkg"?`describe('${e.name}', () => {
|
|
40
40
|
it('should add two numbers correctly', () => {
|
|
41
41
|
expect(add(1, 1)).toBe(2);
|
|
42
42
|
});
|
|
@@ -47,13 +47,13 @@ import stylistic from '@stylistic/eslint-plugin';
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
`,o=i("test/index.test.ts",e)+s("PACK",`import { describe, it, expect } from 'bun:test';
|
|
50
|
-
`+(
|
|
51
|
-
`:""))+s("TEST",
|
|
52
|
-
`}function b(
|
|
53
|
-
`)+s("CONST",`const rules = ${
|
|
50
|
+
`+(t==="pkg"?`import { add } from '../src';
|
|
51
|
+
`:""))+s("TEST",n),r=mcs_fmt.formatTS(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
|
+
`}function b(t,e){let n={clean:true,dts:true,entry:["src/index.ts"],format:["esm","cjs"],minify:true,sourcemap:false,splitting:true};t==="pkg"&&Object.assign(n,{clean:true,dts:true,entry:["src/index.ts"],format:["esm","cjs"],minify:true,sourcemap:false,splitting:false,treeshake:true,external:["bun"],target:"es2022",outDir:"dist"}),t==="cli"&&(n.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(JSON.stringify(n)).formatted}`)+s("CONF",`// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
54
|
export default defineConfig(rules as any);
|
|
55
|
-
`),r=
|
|
56
|
-
`}function h(){return`# Dependencies
|
|
55
|
+
`),r=mcs_fmt.formatTS(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
57
|
node_modules/
|
|
58
58
|
package-lock.json
|
|
59
59
|
yarn.lock
|
|
@@ -85,9 +85,9 @@ Thumbs.db
|
|
|
85
85
|
# Test coverage
|
|
86
86
|
coverage/
|
|
87
87
|
.nyc_output/
|
|
88
|
-
`}function v(
|
|
88
|
+
`}function v(t){let e=t.author.name||"",n=t.author.email||"",o=typeof t.author.github=="string"?t.author.github.trim():"",r=o?o.includes("github.com")?o:`https://github.com/${o.replace(/^@/,"")}`:"";return e?r?`${e} (${r})`:n?`${e} (${n})`:e:""}function A(t){let e=new Date().getFullYear(),n=v(t);return `Copyright (c) ${e}${n?" "+n:""}`}function x(t){return `MIT License
|
|
89
89
|
|
|
90
|
-
${A(
|
|
90
|
+
${A(t)}
|
|
91
91
|
|
|
92
92
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
93
93
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -106,7 +106,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
106
106
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
107
107
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
108
108
|
SOFTWARE.
|
|
109
|
-
`}function E(){return`# Source and test files
|
|
109
|
+
`}function E(){return `# Source and test files
|
|
110
110
|
src/
|
|
111
111
|
test/
|
|
112
112
|
*.test.ts
|
|
@@ -151,21 +151,21 @@ bun.lockb
|
|
|
151
151
|
*.swp
|
|
152
152
|
*.swo
|
|
153
153
|
*~
|
|
154
|
-
`}function T(
|
|
155
|
-
`}function L(
|
|
154
|
+
`}function T(t,e){let n=t==="cli"?L(e):$(e),o=mcs_fmt.formatMD(n,"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(t){return `# ${t.name}
|
|
156
156
|
|
|
157
|
-
${
|
|
157
|
+
${t.description||"A TypeScript command-line tool."}
|
|
158
158
|
|
|
159
159
|
## Installation
|
|
160
160
|
|
|
161
161
|
\`\`\`bash
|
|
162
|
-
pkg install -g ${
|
|
162
|
+
pkg install -g ${t.name}
|
|
163
163
|
\`\`\`
|
|
164
164
|
|
|
165
165
|
## Usage
|
|
166
166
|
|
|
167
167
|
\`\`\`bash
|
|
168
|
-
${
|
|
168
|
+
${t.name} --help
|
|
169
169
|
\`\`\`
|
|
170
170
|
|
|
171
171
|
## Development
|
|
@@ -179,21 +179,21 @@ pkg build # Build for production
|
|
|
179
179
|
|
|
180
180
|
## License
|
|
181
181
|
|
|
182
|
-
${
|
|
183
|
-
`}function $(
|
|
182
|
+
${t.license}`+(t.author.name?` \xA9 ${new Date().getFullYear()} ${t.author.name}`:"")+`
|
|
183
|
+
`}function $(t){return `# ${t.name}
|
|
184
184
|
|
|
185
|
-
${
|
|
185
|
+
${t.description||"A TypeScript library."}
|
|
186
186
|
|
|
187
187
|
## Installation
|
|
188
188
|
|
|
189
189
|
\`\`\`bash
|
|
190
|
-
pkg install ${
|
|
190
|
+
pkg install ${t.name}
|
|
191
191
|
\`\`\`
|
|
192
192
|
|
|
193
193
|
## Usage
|
|
194
194
|
|
|
195
195
|
\`\`\`typescript
|
|
196
|
-
import { example } from '${
|
|
196
|
+
import { example } from '${t.name}'
|
|
197
197
|
|
|
198
198
|
example()
|
|
199
199
|
\`\`\`
|
|
@@ -209,5 +209,5 @@ pkg test # Run tests
|
|
|
209
209
|
|
|
210
210
|
## License
|
|
211
211
|
|
|
212
|
-
${
|
|
213
|
-
`}var S=class extends Error{constructor(
|
|
212
|
+
${t.license}`+(t.author.name?` \xA9 ${new Date().getFullYear()} ${t.author.name}`:"")+`
|
|
213
|
+
`}var S=class extends Error{constructor(n,o,r){super(n);this.code=o;this.ctx=r;this.name="PkgError";}};function Fe(t,e,n){switch(t){case "package.json":return u(e,n);case "tsconfig.json":return p(e);case ".vscode/settings.json":return m();case "tsup.config.ts":return b(e,n);case "eslint.config.mjs":return d(e,n);case "src/index.ts":return f(e,n);case "test/index.test.ts":return y(e,n);case "README.md":return T(e,n);case ".gitignore":return h();case ".npmignore":return E();case "LICENSE":return x(n);default:throw new Error(`Unknown file: ${t}`)}}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.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import{formatJSON
|
|
2
|
-
`}
|
|
3
|
-
`}
|
|
4
|
-
`}
|
|
1
|
+
import {formatJSON,formatTS,formatMD}from'@langpkg/mcs_fmt';function m(){let e=formatJSON(JSON.stringify({"files.exclude":{"**/.git":true,"**/.svn":true,"**/.hg":true,"**/.DS_Store":true,"**/Thumbs.db":true,"eslint.config.mjs":true,"bun.lock":true,"package-lock.json":true,LICENSE:true,".gitignore":true,".gitattributes":true,".npmignore":true,node_modules:true,"tsup.config.ts":true,"tsconfig.json":true},"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
|
+
`}function u(t,e){let n=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:n?{type:"git",url:`git+${n}.git`}:"",type:"module",files:["dist"],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(t==="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=formatJSON(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
|
+
`}function p(t){let n=formatJSON(JSON.stringify({compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",lib:["DOM","ES2020","ESNext"],types:["node"],declaration:t==="pkg",outDir:"./dist",strict:true,esModuleInterop:true,skipLibCheck:true,forceConsistentCasingInFileNames:true,resolveJsonModule:true,isolatedModules:true,allowImportingTsExtensions:true,noEmit:true,ignoreDeprecations:"6.0"},include:["src","test"],exclude:["node_modules","dist"]}),"tsconfig.json");if(n.errors?.length)throw console.error("Error formatting tsconfig.json:",JSON.stringify(n.errors,null,2)),new Error("Failed to generate tsconfig.json due to formatting errors.");return n.formatted+`
|
|
4
|
+
`}function s(t,e,n=true){let o=n?`
|
|
5
5
|
|
|
6
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 "+
|
|
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 "+t+` \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
8
|
|
|
9
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
10
|
`;return e=e.split(`
|
|
11
11
|
`).map(a=>a===""?a:" "+a).join(`
|
|
12
12
|
`),o+r+e+`
|
|
13
|
-
`+c}function i(
|
|
13
|
+
`+c}function i(t,e){let n=e.author.name?`// Made with \u2764\uFE0F by ${e.author.name}.`:"// Made with \u2764\uFE0F by Maysara.";return `// ${t}
|
|
14
14
|
//
|
|
15
|
-
${
|
|
16
|
-
`}function f(
|
|
17
|
-
`:"");if(
|
|
18
|
-
`);else{let r=`export const run = (): void => {
|
|
15
|
+
${n}
|
|
16
|
+
`}function f(t,e){let n=i("src/index.ts",e)+s("PACK",t==="cli"?`import { cli } from '@langpkg/cli';
|
|
17
|
+
`:"");if(t==="pkg")n+=s("MAIN",`export const add = (a: number, b: number): number => a + b;
|
|
18
|
+
`);else {let r=`export const run = (): void => {
|
|
19
19
|
console.log('${e.name} running...');
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
run();
|
|
23
|
-
`;
|
|
24
|
-
`}
|
|
23
|
+
`;n+=s("MAIN",r);}let o=formatTS(n,"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
|
+
`}function d(t,e){let n={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:false,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:false,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
25
|
import js from '@eslint/js';
|
|
26
26
|
import tseslint from 'typescript-eslint';
|
|
27
27
|
import stylistic from '@stylistic/eslint-plugin';
|
|
28
|
-
`)+s("CONST",`const rules = ${
|
|
28
|
+
`)+s("CONST",`const rules = ${formatJSON(JSON.stringify(n)).formatted}`)+s("CONF",`export default defineConfig(
|
|
29
29
|
|
|
30
30
|
js.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic,
|
|
31
31
|
|
|
@@ -35,8 +35,8 @@ import stylistic from '@stylistic/eslint-plugin';
|
|
|
35
35
|
rules : rules
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
|
-
`),r=
|
|
39
|
-
`}
|
|
38
|
+
`),r=formatTS(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
|
+
`}function y(t,e){let n=t==="pkg"?`describe('${e.name}', () => {
|
|
40
40
|
it('should add two numbers correctly', () => {
|
|
41
41
|
expect(add(1, 1)).toBe(2);
|
|
42
42
|
});
|
|
@@ -47,13 +47,13 @@ import stylistic from '@stylistic/eslint-plugin';
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
`,o=i("test/index.test.ts",e)+s("PACK",`import { describe, it, expect } from 'bun:test';
|
|
50
|
-
`+(
|
|
51
|
-
`:""))+s("TEST",
|
|
52
|
-
`}
|
|
53
|
-
`)+s("CONST",`const rules = ${
|
|
50
|
+
`+(t==="pkg"?`import { add } from '../src';
|
|
51
|
+
`:""))+s("TEST",n),r=formatTS(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
|
+
`}function b(t,e){let n={clean:true,dts:true,entry:["src/index.ts"],format:["esm","cjs"],minify:true,sourcemap:false,splitting:true};t==="pkg"&&Object.assign(n,{clean:true,dts:true,entry:["src/index.ts"],format:["esm","cjs"],minify:true,sourcemap:false,splitting:false,treeshake:true,external:["bun"],target:"es2022",outDir:"dist"}),t==="cli"&&(n.banner={js:"#!/usr/bin/env bun"});let o=i("tsup.config.ts",e)+s("PACK",`import { defineConfig } from 'tsup';
|
|
53
|
+
`)+s("CONST",`const rules = ${formatJSON(JSON.stringify(n)).formatted}`)+s("CONF",`// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
54
|
export default defineConfig(rules as any);
|
|
55
|
-
`),r=
|
|
56
|
-
`}function h(){return`# Dependencies
|
|
55
|
+
`),r=formatTS(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
57
|
node_modules/
|
|
58
58
|
package-lock.json
|
|
59
59
|
yarn.lock
|
|
@@ -85,9 +85,9 @@ Thumbs.db
|
|
|
85
85
|
# Test coverage
|
|
86
86
|
coverage/
|
|
87
87
|
.nyc_output/
|
|
88
|
-
`}function v(
|
|
88
|
+
`}function v(t){let e=t.author.name||"",n=t.author.email||"",o=typeof t.author.github=="string"?t.author.github.trim():"",r=o?o.includes("github.com")?o:`https://github.com/${o.replace(/^@/,"")}`:"";return e?r?`${e} (${r})`:n?`${e} (${n})`:e:""}function A(t){let e=new Date().getFullYear(),n=v(t);return `Copyright (c) ${e}${n?" "+n:""}`}function x(t){return `MIT License
|
|
89
89
|
|
|
90
|
-
${A(
|
|
90
|
+
${A(t)}
|
|
91
91
|
|
|
92
92
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
93
93
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -106,7 +106,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
106
106
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
107
107
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
108
108
|
SOFTWARE.
|
|
109
|
-
`}function E(){return`# Source and test files
|
|
109
|
+
`}function E(){return `# Source and test files
|
|
110
110
|
src/
|
|
111
111
|
test/
|
|
112
112
|
*.test.ts
|
|
@@ -151,21 +151,21 @@ bun.lockb
|
|
|
151
151
|
*.swp
|
|
152
152
|
*.swo
|
|
153
153
|
*~
|
|
154
|
-
`}
|
|
155
|
-
`}function L(
|
|
154
|
+
`}function T(t,e){let n=t==="cli"?L(e):$(e),o=formatMD(n,"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(t){return `# ${t.name}
|
|
156
156
|
|
|
157
|
-
${
|
|
157
|
+
${t.description||"A TypeScript command-line tool."}
|
|
158
158
|
|
|
159
159
|
## Installation
|
|
160
160
|
|
|
161
161
|
\`\`\`bash
|
|
162
|
-
pkg install -g ${
|
|
162
|
+
pkg install -g ${t.name}
|
|
163
163
|
\`\`\`
|
|
164
164
|
|
|
165
165
|
## Usage
|
|
166
166
|
|
|
167
167
|
\`\`\`bash
|
|
168
|
-
${
|
|
168
|
+
${t.name} --help
|
|
169
169
|
\`\`\`
|
|
170
170
|
|
|
171
171
|
## Development
|
|
@@ -179,21 +179,21 @@ pkg build # Build for production
|
|
|
179
179
|
|
|
180
180
|
## License
|
|
181
181
|
|
|
182
|
-
${
|
|
183
|
-
`}function $(
|
|
182
|
+
${t.license}`+(t.author.name?` \xA9 ${new Date().getFullYear()} ${t.author.name}`:"")+`
|
|
183
|
+
`}function $(t){return `# ${t.name}
|
|
184
184
|
|
|
185
|
-
${
|
|
185
|
+
${t.description||"A TypeScript library."}
|
|
186
186
|
|
|
187
187
|
## Installation
|
|
188
188
|
|
|
189
189
|
\`\`\`bash
|
|
190
|
-
pkg install ${
|
|
190
|
+
pkg install ${t.name}
|
|
191
191
|
\`\`\`
|
|
192
192
|
|
|
193
193
|
## Usage
|
|
194
194
|
|
|
195
195
|
\`\`\`typescript
|
|
196
|
-
import { example } from '${
|
|
196
|
+
import { example } from '${t.name}'
|
|
197
197
|
|
|
198
198
|
example()
|
|
199
199
|
\`\`\`
|
|
@@ -209,5 +209,5 @@ pkg test # Run tests
|
|
|
209
209
|
|
|
210
210
|
## License
|
|
211
211
|
|
|
212
|
-
${
|
|
213
|
-
`}var S=class extends Error{constructor(
|
|
212
|
+
${t.license}`+(t.author.name?` \xA9 ${new Date().getFullYear()} ${t.author.name}`:"")+`
|
|
213
|
+
`}var S=class extends Error{constructor(n,o,r){super(n);this.code=o;this.ctx=r;this.name="PkgError";}};function Fe(t,e,n){switch(t){case "package.json":return u(e,n);case "tsconfig.json":return p(e);case ".vscode/settings.json":return m();case "tsup.config.ts":return b(e,n);case "eslint.config.mjs":return d(e,n);case "src/index.ts":return f(e,n);case "test/index.test.ts":return y(e,n);case "README.md":return T(e,n);case ".gitignore":return h();case ".npmignore":return E();case "LICENSE":return x(n);default:throw new Error(`Unknown file: ${t}`)}}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.4",
|
|
4
4
|
"description": "maysara code style generator",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": ["dist"],
|
|
15
16
|
"exports": {
|
|
16
17
|
".": {
|
|
17
18
|
"import": "./dist/index.js",
|
|
@@ -20,23 +21,23 @@
|
|
|
20
21
|
},
|
|
21
22
|
"module": "./dist/index.js",
|
|
22
23
|
"pkg": {
|
|
23
|
-
"type": "
|
|
24
|
+
"type": "pkg"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@langpkg/mcs_fmt": "^0.0.
|
|
28
|
+
"@langpkg/mcs_fmt": "^0.0.5",
|
|
28
29
|
"glob": "^13.0.6"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@eslint/js": "^10.0.1",
|
|
32
33
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
33
34
|
"@types/bun": "^1.3.14",
|
|
34
|
-
"@types/node": "^25.
|
|
35
|
+
"@types/node": "^25.9.1",
|
|
35
36
|
"bun-plugin-dts": "^0.4.0",
|
|
36
37
|
"bun-types": "^1.3.14",
|
|
37
38
|
"ts-node": "^10.9.2",
|
|
38
39
|
"tsup": "^8.5.1",
|
|
39
40
|
"typescript": "^6.0.3",
|
|
40
|
-
"typescript-eslint": "^8.59.
|
|
41
|
+
"typescript-eslint": "^8.59.4"
|
|
41
42
|
}
|
|
42
43
|
}
|