@langpkg/mcs_gen 0.0.1 → 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 +3 -3
- 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/src/gen/text/license.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// src/gen/text/license.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import type { ProjectMeta } from '../../common';
|
|
10
|
-
|
|
11
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// ╔════════════════════════════════════════ HELP ════════════════════════════════════════╗
|
|
16
|
-
|
|
17
|
-
function buildCopyrightHolder(meta: ProjectMeta): string {
|
|
18
|
-
const name = meta.author.name || '';
|
|
19
|
-
const email = meta.author.email || '';
|
|
20
|
-
const rawGithub = typeof meta.author.github === 'string' ? meta.author.github.trim() : '';
|
|
21
|
-
const github = rawGithub
|
|
22
|
-
? rawGithub.includes('github.com')
|
|
23
|
-
? rawGithub
|
|
24
|
-
: `https://github.com/${rawGithub.replace(/^@/, '')}`
|
|
25
|
-
: '';
|
|
26
|
-
const holder = name
|
|
27
|
-
? github
|
|
28
|
-
? `${name} (${github})`
|
|
29
|
-
: email
|
|
30
|
-
? `${name} (${email})`
|
|
31
|
-
: name
|
|
32
|
-
: '';
|
|
33
|
-
|
|
34
|
-
return holder;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function buildCopyright(meta: ProjectMeta): string {
|
|
38
|
-
const year = new Date().getFullYear();
|
|
39
|
-
const holder = buildCopyrightHolder(meta);
|
|
40
|
-
return `Copyright (c) ${year}${holder ? ' ' + holder : ''}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
48
|
-
|
|
49
|
-
export function generateLicense(meta: ProjectMeta): string {
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
'MIT License\n\n' +
|
|
53
|
-
`${buildCopyright(meta)}\n\n` +
|
|
54
|
-
'Permission is hereby granted, free of charge, to any person obtaining a copy\n' +
|
|
55
|
-
'of this software and associated documentation files (the "Software"), to deal\n' +
|
|
56
|
-
'in the Software without restriction, including without limitation the rights\n' +
|
|
57
|
-
'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n' +
|
|
58
|
-
'copies of the Software, and to permit persons to whom the Software is\n' +
|
|
59
|
-
'furnished to do so, subject to the following conditions:\n\n' +
|
|
60
|
-
'The above copyright notice and this permission notice shall be included in all\n' +
|
|
61
|
-
'copies or substantial portions of the Software.\n\n' +
|
|
62
|
-
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n' +
|
|
63
|
-
'IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n' +
|
|
64
|
-
'FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n' +
|
|
65
|
-
'AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n' +
|
|
66
|
-
'LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n' +
|
|
67
|
-
'OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n' +
|
|
68
|
-
'SOFTWARE.\n'
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// src/gen/ts/eslint_config.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { formatTS, formatJSON } from '@langpkg/mcs_fmt';
|
|
10
|
-
import type { ProjectType, ProjectMeta } from '../../common';
|
|
11
|
-
|
|
12
|
-
import { genL1, genFileHeader } from './utils';
|
|
13
|
-
|
|
14
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
19
|
-
|
|
20
|
-
export function generateEslintConfig(projectType: ProjectType, meta: ProjectMeta): string {
|
|
21
|
-
|
|
22
|
-
const rulesJSON = {
|
|
23
|
-
curly : 'off',
|
|
24
|
-
'@stylistic/semi' : ['warn', 'always'],
|
|
25
|
-
'@typescript-eslint/no-empty-function' : 'off',
|
|
26
|
-
'@typescript-eslint/naming-convention' : [
|
|
27
|
-
'warn',
|
|
28
|
-
// Variables and parameters: snake_case
|
|
29
|
-
{
|
|
30
|
-
selector : 'variable',
|
|
31
|
-
format : ['snake_case', 'camelCase'],
|
|
32
|
-
filter : {
|
|
33
|
-
match : false,
|
|
34
|
-
regex : '^_',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
// Functions and methods: camelCase
|
|
38
|
-
{
|
|
39
|
-
selector : 'function',
|
|
40
|
-
format : ['camelCase'],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
selector : 'method',
|
|
44
|
-
format : ['camelCase'],
|
|
45
|
-
},
|
|
46
|
-
// Classes and types: PascalCase
|
|
47
|
-
{
|
|
48
|
-
selector : 'typeLike',
|
|
49
|
-
format : ['PascalCase'],
|
|
50
|
-
},
|
|
51
|
-
// Imports: camelCase and PascalCase
|
|
52
|
-
{
|
|
53
|
-
selector : 'import',
|
|
54
|
-
format : ['camelCase', 'PascalCase'],
|
|
55
|
-
},
|
|
56
|
-
// Constants: UPPER_CASE
|
|
57
|
-
{
|
|
58
|
-
selector : 'variable',
|
|
59
|
-
modifiers : ['const'],
|
|
60
|
-
format : ['UPPER_CASE', 'snake_case', 'camelCase'],
|
|
61
|
-
filter : {
|
|
62
|
-
match : false,
|
|
63
|
-
regex : '^_',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
// Enum members: PascalCase
|
|
67
|
-
{
|
|
68
|
-
selector : 'enumMember',
|
|
69
|
-
format : ['PascalCase'],
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
|
|
73
|
-
'@typescript-eslint/no-unused-vars' : ['error', { argsIgnorePattern: '^_' }],
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const content = (
|
|
77
|
-
genFileHeader('eslint.config.ts', meta) +
|
|
78
|
-
genL1(
|
|
79
|
-
'PACK',
|
|
80
|
-
"import { defineConfig } from 'eslint/config';\n" +
|
|
81
|
-
"import js from '@eslint/js';\n" +
|
|
82
|
-
"import tseslint from 'typescript-eslint';\n" +
|
|
83
|
-
"import stylistic from '@stylistic/eslint-plugin';\n"
|
|
84
|
-
) +
|
|
85
|
-
genL1(
|
|
86
|
-
'CONST',
|
|
87
|
-
`const rules = ${formatJSON(JSON.stringify(rulesJSON)).formatted}`
|
|
88
|
-
) +
|
|
89
|
-
genL1(
|
|
90
|
-
'CONF',
|
|
91
|
-
'export default defineConfig(\n' +
|
|
92
|
-
'\n' +
|
|
93
|
-
' js.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic,\n' +
|
|
94
|
-
'\n' +
|
|
95
|
-
' {\n' +
|
|
96
|
-
` ignores : ['**/.vscode-test', '**/out', 'dist/', 'node_modules/', '.git/'],\n` +
|
|
97
|
-
" plugins : { '@stylistic': stylistic },\n" +
|
|
98
|
-
' rules : rules\n' +
|
|
99
|
-
' }\n' +
|
|
100
|
-
');\n'
|
|
101
|
-
)
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const result = formatTS(content, 'eslint.config.ts');
|
|
105
|
-
|
|
106
|
-
if(result.errors?.length) {
|
|
107
|
-
console.error('Error formatting eslint.config.ts:', JSON.stringify(result.errors, null, 2));
|
|
108
|
-
throw new Error('Failed to generate eslint.config.ts due to formatting errors.');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return result.formatted + '\n';
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/ts/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/gen/ts/index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
export { generateSourceIndexTs } from './source_index';
|
|
10
|
-
export { generateEslintConfig } from './eslint_config';
|
|
11
|
-
export { generateTestIndexTs } from './test_index';
|
|
12
|
-
export { generateTsupConfig } from './tsup_config';
|
|
13
|
-
|
|
14
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/gen/ts/source_index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { formatTS } from '@langpkg/mcs_fmt';
|
|
10
|
-
import type { ProjectType, ProjectMeta } from '../../common';
|
|
11
|
-
|
|
12
|
-
import { genL1, genFileHeader } from './utils';
|
|
13
|
-
|
|
14
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
19
|
-
|
|
20
|
-
export function generateSourceIndexTs(projectType: ProjectType, meta: ProjectMeta): string {
|
|
21
|
-
|
|
22
|
-
let content =
|
|
23
|
-
genFileHeader('src/index.ts', meta) +
|
|
24
|
-
genL1(
|
|
25
|
-
'PACK',
|
|
26
|
-
projectType === 'cli' ? "import { cli } from '@langpkg/cli';\n" : ''
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if (projectType === 'pkg') {
|
|
30
|
-
const code = 'export const add = (a: number, b: number): number => a + b;\n';
|
|
31
|
-
|
|
32
|
-
content += genL1('MAIN', code);
|
|
33
|
-
} else {
|
|
34
|
-
const code =
|
|
35
|
-
'export const run = (): void => {\n' +
|
|
36
|
-
` console.log('${meta.name} running...');\n` +
|
|
37
|
-
'};\n\n' +
|
|
38
|
-
'run();\n';
|
|
39
|
-
|
|
40
|
-
content += genL1('MAIN', code);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const result = formatTS(content, 'src/index.ts');
|
|
44
|
-
|
|
45
|
-
if(result.errors?.length) {
|
|
46
|
-
console.error('Error formatting src/index.ts:', JSON.stringify(result.errors, null, 2));
|
|
47
|
-
throw new Error('Failed to generate src/index.ts due to formatting errors.');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return result.formatted + '\n';
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/ts/test_index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/gen/ts/test_index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { formatTS } from '@langpkg/mcs_fmt';
|
|
10
|
-
import type { ProjectType, ProjectMeta } from '../../common';
|
|
11
|
-
|
|
12
|
-
import { genFileHeader, genL1 } from './utils';
|
|
13
|
-
|
|
14
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
19
|
-
|
|
20
|
-
export function generateTestIndexTs(projectType: ProjectType, meta: ProjectMeta): string {
|
|
21
|
-
|
|
22
|
-
const code =
|
|
23
|
-
projectType === 'pkg'
|
|
24
|
-
? `describe('${meta.name}', () => {\n` +
|
|
25
|
-
" it('should add two numbers correctly', () => {\n" +
|
|
26
|
-
' expect(add(1, 1)).toBe(2);\n' +
|
|
27
|
-
' });\n' +
|
|
28
|
-
'});\n'
|
|
29
|
-
: `describe('CLI', () => {\n` +
|
|
30
|
-
" it('should run without errors', () => {\n" +
|
|
31
|
-
` expect(() => run()).not.toThrow();\n` +
|
|
32
|
-
' });\n' +
|
|
33
|
-
'});\n';
|
|
34
|
-
|
|
35
|
-
const content =
|
|
36
|
-
genFileHeader('test/index.test.ts', meta) +
|
|
37
|
-
genL1(
|
|
38
|
-
'PACK',
|
|
39
|
-
"import { describe, it, expect } from 'bun:test';\n" +
|
|
40
|
-
(projectType === 'pkg' ? "import { add } from '../src';\n" : '')
|
|
41
|
-
) + genL1('TEST', code);
|
|
42
|
-
|
|
43
|
-
const result = formatTS(content, 'test/index.test.ts');
|
|
44
|
-
|
|
45
|
-
if(result.errors?.length) {
|
|
46
|
-
console.error('Error formatting test/index.test.ts:', JSON.stringify(result.errors, null, 2));
|
|
47
|
-
throw new Error('Failed to generate test/index.test.ts due to formatting errors.');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return result.formatted + '\n';
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// src/gen/ts/tsup_config.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { formatJSON, formatTS } from '@langpkg/mcs_fmt';
|
|
10
|
-
import type { ProjectType, ProjectMeta } from '../../common';
|
|
11
|
-
|
|
12
|
-
import { genL1, genFileHeader } from './utils';
|
|
13
|
-
|
|
14
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
19
|
-
|
|
20
|
-
export function generateTsupConfig(projectType: ProjectType, meta: ProjectMeta): string {
|
|
21
|
-
|
|
22
|
-
const configObj: Record<string, unknown> = {
|
|
23
|
-
entry : ['src/index.ts'],
|
|
24
|
-
format : ['esm', 'cjs'],
|
|
25
|
-
dts : true,
|
|
26
|
-
minify : true,
|
|
27
|
-
sourcemap : false,
|
|
28
|
-
clean : true,
|
|
29
|
-
splitting : true,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Add banner with shebang for CLI projects
|
|
33
|
-
if (projectType === 'cli') {
|
|
34
|
-
configObj.banner = { js: '#!/usr/bin/env bun' };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const content = (
|
|
38
|
-
genFileHeader('tsup.config.ts', meta) +
|
|
39
|
-
genL1(
|
|
40
|
-
'PACK',
|
|
41
|
-
"import { defineConfig } from 'tsup';\n"
|
|
42
|
-
) +
|
|
43
|
-
genL1(
|
|
44
|
-
'CONST',
|
|
45
|
-
`const rules = ${formatJSON(JSON.stringify(configObj)).formatted}`
|
|
46
|
-
) +
|
|
47
|
-
genL1(
|
|
48
|
-
'CONF',
|
|
49
|
-
'// eslint-disable-next-line @typescript-eslint/no-explicit-any\n' +
|
|
50
|
-
'export default defineConfig(rules as any);\n'
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const result = formatTS(content, 'tsup.config.ts');
|
|
55
|
-
|
|
56
|
-
if(result.errors?.length) {
|
|
57
|
-
console.error('Error formatting tsup.config.ts:', JSON.stringify(result.errors, null, 2));
|
|
58
|
-
throw new Error('Failed to generate tsup.config.ts due to formatting errors.');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return result.formatted + '\n';
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/ts/utils.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// src/gen/ts/utils.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import type { ProjectMeta } from '../../common/types';
|
|
10
|
-
|
|
11
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// ╔════════════════════════════════════════ UTIL ════════════════════════════════════════╗
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Generate a file section with decorative headers and footer
|
|
19
|
-
* Used for organizing TypeScript/JavaScript source files
|
|
20
|
-
*/
|
|
21
|
-
export function genL1(name: string, content: string, sep = true): string {
|
|
22
|
-
const _sep = sep ? '\n\n\n' : '';
|
|
23
|
-
|
|
24
|
-
const l1Open =
|
|
25
|
-
'// ╔════════════════════════════════════════ ' + name + ' ════════════════════════════════════════╗\n\n';
|
|
26
|
-
|
|
27
|
-
const l1Close =
|
|
28
|
-
'// ╚══════════════════════════════════════════════════════════════════════════════════════╝\n';
|
|
29
|
-
|
|
30
|
-
// content comes in same level, must add extra indentation to fit inside the section (4 spaces)
|
|
31
|
-
content = content
|
|
32
|
-
.split('\n')
|
|
33
|
-
.map((line) => (line === '' ? line : ' ' + line))
|
|
34
|
-
.join('\n');
|
|
35
|
-
|
|
36
|
-
return _sep + l1Open + content + '\n' + l1Close;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Generate a file header with author line
|
|
41
|
-
* Used for all source files to maintain consistent header format
|
|
42
|
-
* Note: Shebang for CLI projects is added by tsup via banner configuration
|
|
43
|
-
*/
|
|
44
|
-
export function genFileHeader(
|
|
45
|
-
file_path : string,
|
|
46
|
-
meta : ProjectMeta
|
|
47
|
-
): string {
|
|
48
|
-
const authorLine = meta.author.name
|
|
49
|
-
? `// Made with ❤️ by ${meta.author.name}.`
|
|
50
|
-
: '// Made with ❤️ by Maysara.';
|
|
51
|
-
|
|
52
|
-
return `// ${file_path}\n//\n${authorLine}\n`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/index.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { generateVscodeSettings } from './gen/json';
|
|
10
|
-
import { generateSourceIndexTs } from './gen/ts';
|
|
11
|
-
import { generateEslintConfig } from './gen/ts';
|
|
12
|
-
import { generateTestIndexTs } from './gen/ts';
|
|
13
|
-
import { generatePackageJson } from './gen/json';
|
|
14
|
-
import { generateTsupConfig } from './gen/ts';
|
|
15
|
-
import { generateGitignore } from './gen/text';
|
|
16
|
-
import { generateTsconfig } from './gen/json';
|
|
17
|
-
import { generateLicense } from './gen/text';
|
|
18
|
-
import { generateReadme } from './gen/md';
|
|
19
|
-
import type { ProjectType, ProjectMeta } from './common';
|
|
20
|
-
export * from './gen/ts';
|
|
21
|
-
export * from './gen/md';
|
|
22
|
-
export * from './gen/json';
|
|
23
|
-
export * from './gen/text';
|
|
24
|
-
export * from './common/types';
|
|
25
|
-
|
|
26
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Main entry point for file generation
|
|
34
|
-
* Routes filename to the appropriate generator function
|
|
35
|
-
*/
|
|
36
|
-
export function generateFile(
|
|
37
|
-
filename : string,
|
|
38
|
-
projectType : ProjectType,
|
|
39
|
-
meta : ProjectMeta
|
|
40
|
-
): string {
|
|
41
|
-
switch (filename) {
|
|
42
|
-
|
|
43
|
-
// JSON files
|
|
44
|
-
case 'package.json' : return generatePackageJson(projectType, meta);
|
|
45
|
-
case 'tsconfig.json' : return generateTsconfig(projectType);
|
|
46
|
-
case '.vscode/settings.json' : return generateVscodeSettings();
|
|
47
|
-
|
|
48
|
-
// Code files
|
|
49
|
-
case 'tsup.config.ts' : return generateTsupConfig(projectType, meta);
|
|
50
|
-
case 'eslint.config.mjs' : return generateEslintConfig(projectType, meta);
|
|
51
|
-
case 'src/index.ts' : return generateSourceIndexTs(projectType, meta);
|
|
52
|
-
case 'test/index.test.ts' : return generateTestIndexTs(projectType, meta);
|
|
53
|
-
|
|
54
|
-
// Markdown files
|
|
55
|
-
case 'README.md' : return generateReadme(projectType, meta);
|
|
56
|
-
|
|
57
|
-
// Text files
|
|
58
|
-
case '.gitignore' : return generateGitignore();
|
|
59
|
-
case 'LICENSE' : return generateLicense(meta);
|
|
60
|
-
|
|
61
|
-
// If filename doesn't match any known generator, throw an error
|
|
62
|
-
default: {
|
|
63
|
-
throw new Error(`Unknown file: ${filename}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/test/.gitkeep
DELETED
|
File without changes
|
package/test/index.test.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// test/index.test.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect } from 'bun:test';
|
|
10
|
-
|
|
11
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// ╔════════════════════════════════════════ TEST ════════════════════════════════════════╗
|
|
16
|
-
|
|
17
|
-
describe('@langpkg/mcs_gen', () => {
|
|
18
|
-
it('temp test', () => {
|
|
19
|
-
expect(1 + 1).toBe(2);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
"compilerOptions" : {
|
|
4
|
-
"target" : "ES2020",
|
|
5
|
-
"lib" : ["DOM", "ES2020", "ESNext"],
|
|
6
|
-
"module" : "ESNext",
|
|
7
|
-
"moduleResolution" : "bundler",
|
|
8
|
-
"types" : ["bun"],
|
|
9
|
-
"allowImportingTsExtensions" : true,
|
|
10
|
-
"resolveJsonModule" : true,
|
|
11
|
-
"declaration" : true,
|
|
12
|
-
"outDir" : "./dist",
|
|
13
|
-
"noEmit" : true,
|
|
14
|
-
"isolatedModules" : true,
|
|
15
|
-
"esModuleInterop" : true,
|
|
16
|
-
"forceConsistentCasingInFileNames" : true,
|
|
17
|
-
"strict" : true,
|
|
18
|
-
"skipLibCheck" : true,
|
|
19
|
-
"ignoreDeprecations" : "6.0"
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
"include" : ["src", "test"],
|
|
23
|
-
"exclude" : ["node_modules", "dist"]
|
|
24
|
-
|
|
25
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// tsup.config.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { defineConfig } from 'tsup';
|
|
10
|
-
|
|
11
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// ╔═══════════════════════════════════════ CONST ════════════════════════════════════════╗
|
|
16
|
-
|
|
17
|
-
const rules = {
|
|
18
|
-
"clean" : true,
|
|
19
|
-
"dts" : true,
|
|
20
|
-
"entry" : ["src/index.ts"],
|
|
21
|
-
"format" : ["esm", "cjs"],
|
|
22
|
-
"minify" : true,
|
|
23
|
-
"sourcemap" : false,
|
|
24
|
-
"splitting" : true
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// ╔════════════════════════════════════════ CONF ════════════════════════════════════════╗
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
export default defineConfig(rules as any);
|
|
35
|
-
|
|
36
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|