@langpkg/mcs_gen 0.0.2 → 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 +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 +6 -5
- 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/assets/img/line.png
DELETED
|
Binary file
|
package/assets/img/logo.png
DELETED
|
Binary file
|
package/docs/.gitkeep
DELETED
|
File without changes
|
package/eslint.config.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// eslint.config.mjs
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { defineConfig } from 'eslint/config';
|
|
10
|
-
import stylistic from '@stylistic/eslint-plugin';
|
|
11
|
-
import tseslint from 'typescript-eslint';
|
|
12
|
-
import js from '@eslint/js';
|
|
13
|
-
|
|
14
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// ╔═══════════════════════════════════════ CONST ════════════════════════════════════════╗
|
|
19
|
-
|
|
20
|
-
const rules = {
|
|
21
|
-
"curly" : "off",
|
|
22
|
-
"@stylistic/semi" : ["warn", "always"],
|
|
23
|
-
"@typescript-eslint/no-empty-function" : "off",
|
|
24
|
-
"@typescript-eslint/naming-convention" : [
|
|
25
|
-
"warn",
|
|
26
|
-
{
|
|
27
|
-
"selector" : "variable",
|
|
28
|
-
"format" : ["snake_case", "camelCase"],
|
|
29
|
-
"filter" : {
|
|
30
|
-
"match" : false,
|
|
31
|
-
"regex" : "^_"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"selector" : "function",
|
|
36
|
-
"format" : ["camelCase"]
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"selector" : "method",
|
|
40
|
-
"format" : ["camelCase"]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"selector" : "typeLike",
|
|
44
|
-
"format" : ["PascalCase"]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"selector" : "import",
|
|
48
|
-
"format" : ["camelCase", "PascalCase"]
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"selector" : "variable",
|
|
52
|
-
"modifiers" : ["const"],
|
|
53
|
-
"format" : ["UPPER_CASE", "snake_case", "camelCase"],
|
|
54
|
-
"filter" : {
|
|
55
|
-
"match" : false,
|
|
56
|
-
"regex" : "^_"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"selector" : "enumMember",
|
|
61
|
-
"format" : ["PascalCase"]
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"@typescript-eslint/no-unused-vars" : [
|
|
65
|
-
"error",
|
|
66
|
-
{
|
|
67
|
-
"argsIgnorePattern" : "^_"
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// ╔════════════════════════════════════════ CONF ════════════════════════════════════════╗
|
|
77
|
-
|
|
78
|
-
export default defineConfig(
|
|
79
|
-
|
|
80
|
-
js.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic,
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
ignores : ['**/.vscode-test', '**/out', 'dist/', 'node_modules/', '.git/'],
|
|
84
|
-
plugins : { '@stylistic': stylistic },
|
|
85
|
-
rules : rules,
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/common/index.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// src/common/index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { PkgError } from './types';
|
|
10
|
-
import * as path from 'path';
|
|
11
|
-
import * as fs from 'fs';
|
|
12
|
-
import process from 'process';
|
|
13
|
-
export * from './types';
|
|
14
|
-
|
|
15
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// ╔════════════════════════════════════════ FILE ════════════════════════════════════════╗
|
|
20
|
-
|
|
21
|
-
export function resolvePath(filePath: string): string {
|
|
22
|
-
return path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isFileExists(filePath: string): boolean {
|
|
26
|
-
try {
|
|
27
|
-
return fs.existsSync(resolvePath(filePath));
|
|
28
|
-
} catch {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function isDirExists(dirPath: string): boolean {
|
|
34
|
-
try {
|
|
35
|
-
const resolved = resolvePath(dirPath);
|
|
36
|
-
return fs.existsSync(resolved) && fs.statSync(resolved).isDirectory();
|
|
37
|
-
} catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function readFile(filePath: string): string {
|
|
43
|
-
const targetPath = resolvePath(filePath);
|
|
44
|
-
|
|
45
|
-
if (!fs.existsSync(targetPath)) {
|
|
46
|
-
throw new PkgError(`File not found: ${targetPath}`, 'FILE_NOT_FOUND', {
|
|
47
|
-
path : targetPath,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
return fs.readFileSync(targetPath, 'utf-8');
|
|
53
|
-
} catch (error) {
|
|
54
|
-
throw new PkgError(`Failed to read file: ${targetPath}`, 'FILE_READ_ERROR', {
|
|
55
|
-
path : targetPath,
|
|
56
|
-
cause : String(error),
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function writeFile(filePath: string, content: string): void {
|
|
62
|
-
const targetPath = resolvePath(filePath);
|
|
63
|
-
const dir = path.dirname(targetPath);
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); }
|
|
67
|
-
fs.writeFileSync(targetPath, content, 'utf-8');
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw new PkgError(`Failed to write file: ${targetPath}`, 'FILE_WRITE_ERROR', {
|
|
70
|
-
path : targetPath,
|
|
71
|
-
cause : String(error),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function readJsonFile<T = unknown>(filePath: string): T {
|
|
77
|
-
const content = readFile(filePath);
|
|
78
|
-
try {
|
|
79
|
-
return JSON.parse(content) as T;
|
|
80
|
-
} catch (error) {
|
|
81
|
-
throw new PkgError(`Invalid JSON in file: ${filePath}`, 'JSON_PARSE_ERROR', {
|
|
82
|
-
path : filePath,
|
|
83
|
-
cause : String(error),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function writeJsonFile(filePath: string, data: unknown, pretty = true): void {
|
|
89
|
-
const content = pretty ? JSON.stringify(data, null, 4) : JSON.stringify(data);
|
|
90
|
-
writeFile(filePath, content);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// ╔════════════════════════════════════════ PROC ════════════════════════════════════════╗
|
|
98
|
-
|
|
99
|
-
export function getCwd(): string {
|
|
100
|
-
return process.cwd();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function sleep(ms: number): Promise<void> {
|
|
104
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function createDir(dirPath: string): void {
|
|
108
|
-
const fullPath = path.resolve(getCwd(), dirPath);
|
|
109
|
-
fs.mkdirSync(fullPath, { recursive: true });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/common/types.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// src/common/types.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ TYPE ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
export type ProjectType = 'pkg' | 'cli';
|
|
10
|
-
|
|
11
|
-
export interface ProjectMeta {
|
|
12
|
-
name : string;
|
|
13
|
-
version : string;
|
|
14
|
-
description : string;
|
|
15
|
-
license : string;
|
|
16
|
-
author : {
|
|
17
|
-
name : string;
|
|
18
|
-
email : string;
|
|
19
|
-
github : string;
|
|
20
|
-
};
|
|
21
|
-
org : string; // GitHub org or username
|
|
22
|
-
repoName : string; // GitHub repo name
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface FormatResult {
|
|
26
|
-
formatted : string;
|
|
27
|
-
count : number;
|
|
28
|
-
errors? : FormatError[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface FormatError {
|
|
32
|
-
message : string;
|
|
33
|
-
line? : number;
|
|
34
|
-
column? : number;
|
|
35
|
-
[key: string] : unknown;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type IssueSeverity = 'error' | 'warning';
|
|
39
|
-
|
|
40
|
-
export type FormatFix =
|
|
41
|
-
| { type: 'reformat'; content: string }
|
|
42
|
-
| { type: 'replace_line'; line: number; content: string }
|
|
43
|
-
| { type: 'insert_after_line'; line: number; content: string }
|
|
44
|
-
| { type: 'insert_before_line'; line: number; content: string }
|
|
45
|
-
| { type: 'remove_blank_lines'; line: number; count: number }
|
|
46
|
-
| { type: 'append_lines'; content: string };
|
|
47
|
-
|
|
48
|
-
export interface FormatIssue {
|
|
49
|
-
file : string;
|
|
50
|
-
line : number;
|
|
51
|
-
code : string;
|
|
52
|
-
message : string;
|
|
53
|
-
severity : IssueSeverity;
|
|
54
|
-
fixable : boolean;
|
|
55
|
-
fix? : FormatFix;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export class PkgError extends Error {
|
|
59
|
-
constructor(
|
|
60
|
-
msg : string,
|
|
61
|
-
public code : string,
|
|
62
|
-
public ctx? : Record<string, unknown>
|
|
63
|
-
) {
|
|
64
|
-
super(msg);
|
|
65
|
-
this.name = 'PkgError';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/json/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/gen/json/index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
export { generateVscodeSettings } from './vscode_settings';
|
|
10
|
-
export { generatePackageJson } from './package_json';
|
|
11
|
-
export { generateTsconfig } from './tsconfig';
|
|
12
|
-
|
|
13
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// src/gen/json/package_json.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import type { ProjectType, ProjectMeta } from '../../common';
|
|
10
|
-
|
|
11
|
-
import { formatJSON } from '@langpkg/mcs_fmt';
|
|
12
|
-
|
|
13
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
18
|
-
|
|
19
|
-
export function generatePackageJson(projectType: ProjectType, meta: ProjectMeta): string {
|
|
20
|
-
const repoUrl =
|
|
21
|
-
meta.org && meta.repoName ? `https://github.com/${meta.org}/${meta.repoName}` : '';
|
|
22
|
-
|
|
23
|
-
const authorStr = [meta.author.name, meta.author.email ? `<${meta.author.email}>` : '']
|
|
24
|
-
.filter(Boolean)
|
|
25
|
-
.join(' ');
|
|
26
|
-
|
|
27
|
-
// Keys ordered to match PACKAGE_JSON_ORDER in jsonFormat.ts so the
|
|
28
|
-
// generator output is identical to what the validator would produce -
|
|
29
|
-
// no false-positive JSON_FORMAT warning on a freshly initialised project.
|
|
30
|
-
// Order: name, version, description, keywords, license, author,
|
|
31
|
-
// repository, type, [bin (cli only)], main, module, types,
|
|
32
|
-
// exports, scripts, dependencies, devDependencies, [pkg (cli only)]
|
|
33
|
-
const pkgObj: Record<string, unknown> = {
|
|
34
|
-
name : meta.name,
|
|
35
|
-
version : meta.version,
|
|
36
|
-
description : meta.description,
|
|
37
|
-
keywords : [] as string[],
|
|
38
|
-
license : meta.license,
|
|
39
|
-
author : authorStr || '',
|
|
40
|
-
repository : repoUrl ? { type: 'git', url: `git+${repoUrl}.git` } : '',
|
|
41
|
-
type : 'module',
|
|
42
|
-
main : './dist/index.js',
|
|
43
|
-
module : './dist/index.js',
|
|
44
|
-
types : './dist/index.d.ts',
|
|
45
|
-
exports : {
|
|
46
|
-
'.': {
|
|
47
|
-
import : './dist/index.js',
|
|
48
|
-
types : './dist/index.d.ts',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
scripts : {}, // use `pkg` cli instead.
|
|
52
|
-
dependencies : {},
|
|
53
|
-
devDependencies : {
|
|
54
|
-
// default devDependencies
|
|
55
|
-
'@eslint/js' : '^9.39.4',
|
|
56
|
-
'@stylistic/eslint-plugin' : '^5.10.0',
|
|
57
|
-
'@types/bun' : '^1.3.13',
|
|
58
|
-
'@types/node' : '^25.7.0',
|
|
59
|
-
'bun-plugin-dts' : '^0.3.0',
|
|
60
|
-
'bun-types' : '^1.3.13',
|
|
61
|
-
'ts-node' : '^10.9.2',
|
|
62
|
-
'tsup' : '^8.5.1',
|
|
63
|
-
'typescript' : '^5.9.3',
|
|
64
|
-
'typescript-eslint' : '^8.59.3',
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// For CLI mode, add bin field (inserted after 'type', before 'scripts')
|
|
69
|
-
if (projectType === 'cli') {
|
|
70
|
-
const binName = meta.name.replace(/^@[^/]+\//, '');
|
|
71
|
-
const ordered: Record<string, unknown> = {};
|
|
72
|
-
for (const [k, v] of Object.entries(pkgObj)) {
|
|
73
|
-
ordered[k] = v;
|
|
74
|
-
if (k === 'type') {
|
|
75
|
-
ordered['bin'] = { [binName]: './dist/index.js' };
|
|
76
|
-
// Add pkg field for CLI projects
|
|
77
|
-
ordered['pkg'] = { type: 'cli', };
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
Object.keys(pkgObj).forEach((k) => delete pkgObj[k]);
|
|
81
|
-
Object.assign(pkgObj, ordered);
|
|
82
|
-
} else {
|
|
83
|
-
// For normal (library) projects, add pkg field at the end
|
|
84
|
-
pkgObj['pkg'] = { type: 'lib', };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const result = formatJSON(JSON.stringify(pkgObj), 'package.json');
|
|
88
|
-
|
|
89
|
-
if(result.errors?.length) {
|
|
90
|
-
console.error('Error formatting package.json:', JSON.stringify(result.errors, null, 2));
|
|
91
|
-
throw new Error('Failed to generate package.json due to formatting errors.');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return result.formatted + '\n';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/json/tsconfig.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// src/gen/json/tsconfig.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import type { ProjectType } from '../../common';
|
|
10
|
-
|
|
11
|
-
import { formatJSON } from '@langpkg/mcs_fmt';
|
|
12
|
-
|
|
13
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
18
|
-
|
|
19
|
-
export function generateTsconfig(projectType: ProjectType): string {
|
|
20
|
-
|
|
21
|
-
const tsConfig = {
|
|
22
|
-
|
|
23
|
-
compilerOptions : {
|
|
24
|
-
target : 'ES2020',
|
|
25
|
-
module : 'ESNext',
|
|
26
|
-
moduleResolution : 'bundler',
|
|
27
|
-
lib : ['DOM', 'ES2020', 'ESNext'],
|
|
28
|
-
types : ['node'],
|
|
29
|
-
declaration : projectType === 'pkg',
|
|
30
|
-
outDir : './dist',
|
|
31
|
-
// rootDir : './src',
|
|
32
|
-
strict : true,
|
|
33
|
-
esModuleInterop : true,
|
|
34
|
-
skipLibCheck : true,
|
|
35
|
-
forceConsistentCasingInFileNames : true,
|
|
36
|
-
resolveJsonModule : true,
|
|
37
|
-
isolatedModules : true,
|
|
38
|
-
allowImportingTsExtensions : true,
|
|
39
|
-
noEmit : true,
|
|
40
|
-
ignoreDeprecations : "6.0"
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
include : ['src', 'test'],
|
|
44
|
-
exclude : ['node_modules', 'dist']
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const result = formatJSON(JSON.stringify(tsConfig), 'tsconfig.json');
|
|
49
|
-
|
|
50
|
-
if(result.errors?.length) {
|
|
51
|
-
console.error('Error formatting tsconfig.json:', JSON.stringify(result.errors, null, 2));
|
|
52
|
-
throw new Error('Failed to generate tsconfig.json due to formatting errors.');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return result.formatted + '\n';
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// src/gen/json/vscode_settings.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import { formatJSON } from '@langpkg/mcs_fmt';
|
|
10
|
-
|
|
11
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
16
|
-
|
|
17
|
-
export function generateVscodeSettings(): string {
|
|
18
|
-
|
|
19
|
-
const settings = {
|
|
20
|
-
|
|
21
|
-
'files.exclude' : {
|
|
22
|
-
'**/.git' : true,
|
|
23
|
-
'**/.svn' : true,
|
|
24
|
-
'**/.hg' : true,
|
|
25
|
-
'**/.DS_Store' : true,
|
|
26
|
-
'**/Thumbs.db' : true,
|
|
27
|
-
'eslint.config.mjs' : true,
|
|
28
|
-
'bun.lock' : true,
|
|
29
|
-
'package-lock.json' : true,
|
|
30
|
-
'LICENSE' : true,
|
|
31
|
-
'.gitignore' : true,
|
|
32
|
-
'.gitattributes' : true,
|
|
33
|
-
'.npmignore' : true,
|
|
34
|
-
'node_modules' : true,
|
|
35
|
-
'tsup.config.ts' : true,
|
|
36
|
-
'tsconfig.json' : true,
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
'hide-files.files': [
|
|
40
|
-
'eslint.config.mjs',
|
|
41
|
-
'.pkg',
|
|
42
|
-
'.vscode',
|
|
43
|
-
'bun.lock',
|
|
44
|
-
'package-lock.json',
|
|
45
|
-
'LICENSE',
|
|
46
|
-
'.gitignore',
|
|
47
|
-
'.gitattributes',
|
|
48
|
-
'.npmignore',
|
|
49
|
-
'node_modules',
|
|
50
|
-
'tsup.config.ts',
|
|
51
|
-
'tsconfig.json',
|
|
52
|
-
],
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const result = formatJSON(JSON.stringify(settings), '.vscode/settings.json');
|
|
57
|
-
|
|
58
|
-
if(result.errors?.length) {
|
|
59
|
-
console.error('Error formatting vscode settings:', JSON.stringify(result.errors, null, 2));
|
|
60
|
-
throw new Error('Failed to generate vscode settings due to formatting errors.');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return result.formatted + '\n';
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/md/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// src/gen/md/index.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
export { generateReadme } from './readme';
|
|
10
|
-
|
|
11
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
package/src/gen/md/readme.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// src/gen/md/readme.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
import type { ProjectType, ProjectMeta } from '../../common';
|
|
10
|
-
|
|
11
|
-
import { formatMD } from '@langpkg/mcs_fmt';
|
|
12
|
-
|
|
13
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
18
|
-
|
|
19
|
-
export function generateReadme(projectType: ProjectType, meta: ProjectMeta): string {
|
|
20
|
-
// const repoUrl = meta.org && meta.repoName
|
|
21
|
-
// ? `https://github.com/${meta.org}/${meta.repoName}`
|
|
22
|
-
// : '';
|
|
23
|
-
// const badge = repoUrl
|
|
24
|
-
// ? `[](https://www.npmjs.com/package/${meta.name})\n\n`
|
|
25
|
-
// : '';
|
|
26
|
-
|
|
27
|
-
const readmeContent = projectType === 'cli' ? generateCLIReadme(meta) : generateLibReadme(meta);
|
|
28
|
-
const result = formatMD(readmeContent, 'README.md');
|
|
29
|
-
|
|
30
|
-
if(result.errors?.length) {
|
|
31
|
-
console.error('Error formatting readme:', JSON.stringify(result.errors, null, 2));
|
|
32
|
-
throw new Error('Failed to generate readme due to formatting errors.');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return result.formatted + '\n';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// ╔════════════════════════════════════════ HELP ════════════════════════════════════════╗
|
|
43
|
-
|
|
44
|
-
function generateCLIReadme(meta: ProjectMeta): string {
|
|
45
|
-
return (
|
|
46
|
-
`# ${meta.name}\n\n` +
|
|
47
|
-
// badge +
|
|
48
|
-
`${meta.description || 'A TypeScript command-line tool.'}\n\n` +
|
|
49
|
-
'## Installation\n\n```bash\n' +
|
|
50
|
-
`pkg install -g ${meta.name}\n` +
|
|
51
|
-
'```\n\n## Usage\n\n```bash\n' +
|
|
52
|
-
`${meta.name} --help\n` +
|
|
53
|
-
'```\n\n## Development\n\n```bash\npkg install\n' +
|
|
54
|
-
'pkg dev # Build in watch mode (TODO)\n' +
|
|
55
|
-
'pkg lint # Lint code\n' +
|
|
56
|
-
'pkg build # Build for production\n' +
|
|
57
|
-
'```\n\n## License\n\n' +
|
|
58
|
-
`${meta.license}` +
|
|
59
|
-
(meta.author.name ? ` © ${new Date().getFullYear()} ${meta.author.name}` : '') +
|
|
60
|
-
'\n'
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function generateLibReadme(meta: ProjectMeta): string {
|
|
65
|
-
return (
|
|
66
|
-
`# ${meta.name}\n\n` +
|
|
67
|
-
// badge +
|
|
68
|
-
`${meta.description || 'A TypeScript library.'}\n\n` +
|
|
69
|
-
'## Installation\n\n```bash\n' +
|
|
70
|
-
`pkg install ${meta.name}\n` +
|
|
71
|
-
'```\n\n## Usage\n\n```typescript\n' +
|
|
72
|
-
`import { example } from '${meta.name}'\n\nexample()\n` +
|
|
73
|
-
'```\n\n## Development\n\n```bash\npkg install\n' +
|
|
74
|
-
'pkg build # Build distribution files\n' +
|
|
75
|
-
'pkg lint # Lint code\n' +
|
|
76
|
-
'pkg test # Run tests\n' +
|
|
77
|
-
'```\n\n## License\n\n' +
|
|
78
|
-
`${meta.license}` +
|
|
79
|
-
(meta.author.name ? ` © ${new Date().getFullYear()} ${meta.author.name}` : '') +
|
|
80
|
-
'\n'
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/gen/text/gitignore.ts
|
|
2
|
-
//
|
|
3
|
-
// Made with ❤️ by Maysara.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// ╔════════════════════════════════════════ MAIN ════════════════════════════════════════╗
|
|
8
|
-
|
|
9
|
-
export function generateGitignore(): string {
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
'# Dependencies\n' +
|
|
13
|
-
'node_modules/\n' +
|
|
14
|
-
'package-lock.json\n' +
|
|
15
|
-
'yarn.lock\n' +
|
|
16
|
-
'pnpm-lock.yaml\n' +
|
|
17
|
-
'bun.lockb\n\n' +
|
|
18
|
-
'# Build outputs\n' +
|
|
19
|
-
'dist/\n' +
|
|
20
|
-
'build/\n' +
|
|
21
|
-
'*.tsbuildinfo\n\n' +
|
|
22
|
-
'# Environment variables\n' +
|
|
23
|
-
'.env\n' +
|
|
24
|
-
'.env.local\n' +
|
|
25
|
-
'.env.*.local\n\n' +
|
|
26
|
-
'# PKG\n' +
|
|
27
|
-
'.pkg/\n' +
|
|
28
|
-
'# IDE\n' +
|
|
29
|
-
'.vscode/\n' +
|
|
30
|
-
'.idea/\n' +
|
|
31
|
-
'*.swp\n' +
|
|
32
|
-
'*.swo\n\n' +
|
|
33
|
-
'# OS\n' +
|
|
34
|
-
'.DS_Store\n' +
|
|
35
|
-
'Thumbs.db\n\n' +
|
|
36
|
-
'# Test coverage\n' +
|
|
37
|
-
'coverage/\n' +
|
|
38
|
-
'.nyc_output/\n'
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ╚══════════════════════════════════════════════════════════════════════════════════════╝
|