@winccoa-tools-pack/npm-winccoa-ctrl-code-style 0.1.1 → 0.1.2
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/LICENSE +21 -21
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/paths.js +67 -0
- package/dist/cjs/paths.js.map +1 -1
- package/dist/cjs/register.js +10 -3
- package/dist/cjs/register.js.map +1 -1
- package/dist/cjs/style-check.js +12 -2
- package/dist/cjs/style-check.js.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/paths.js +67 -0
- package/dist/esm/paths.js.map +1 -1
- package/dist/esm/register.js +10 -3
- package/dist/esm/register.js.map +1 -1
- package/dist/esm/style-check.js +12 -2
- package/dist/esm/style-check.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/paths.d.ts +26 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/style-check.d.ts +3 -0
- package/dist/style-check.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/check-changelog-version.mjs +37 -37
- package/scripts/fix-esm-imports.mjs +115 -115
- package/scripts/generate-changelog.mjs +190 -190
- package/winccoa/StyleCheck/scripts/astyle.ctl +156 -141
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
/* global console, process */
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
|
|
6
|
-
const repoRoot = path.resolve(process.cwd());
|
|
7
|
-
const packageJsonPath = path.join(repoRoot, 'package.json');
|
|
8
|
-
const changelogPath = path.join(repoRoot, 'CHANGELOG.md');
|
|
9
|
-
|
|
10
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
11
|
-
console.error(`::error::Missing package.json at ${packageJsonPath}`);
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (!fs.existsSync(changelogPath)) {
|
|
16
|
-
console.error(`::error::Missing CHANGELOG.md at ${changelogPath}`);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
21
|
-
const version = String(pkg.version || '').trim();
|
|
22
|
-
|
|
23
|
-
if (!version) {
|
|
24
|
-
console.error('::error::package.json does not contain a valid "version" field');
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const changelog = fs.readFileSync(changelogPath, 'utf8');
|
|
29
|
-
const expectedHeadingPrefix = `## [${version}] - `;
|
|
30
|
-
|
|
31
|
-
if (!changelog.includes(expectedHeadingPrefix)) {
|
|
32
|
-
console.error('::error::Release notes missing in CHANGELOG.md');
|
|
33
|
-
console.error(`Expected CHANGELOG.md to contain a heading like: ${expectedHeadingPrefix}YYYY-MM-DD`);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log(`✅ CHANGELOG.md contains release heading for v${version}`);
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
/* global console, process */
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
const repoRoot = path.resolve(process.cwd());
|
|
7
|
+
const packageJsonPath = path.join(repoRoot, 'package.json');
|
|
8
|
+
const changelogPath = path.join(repoRoot, 'CHANGELOG.md');
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
11
|
+
console.error(`::error::Missing package.json at ${packageJsonPath}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!fs.existsSync(changelogPath)) {
|
|
16
|
+
console.error(`::error::Missing CHANGELOG.md at ${changelogPath}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
21
|
+
const version = String(pkg.version || '').trim();
|
|
22
|
+
|
|
23
|
+
if (!version) {
|
|
24
|
+
console.error('::error::package.json does not contain a valid "version" field');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const changelog = fs.readFileSync(changelogPath, 'utf8');
|
|
29
|
+
const expectedHeadingPrefix = `## [${version}] - `;
|
|
30
|
+
|
|
31
|
+
if (!changelog.includes(expectedHeadingPrefix)) {
|
|
32
|
+
console.error('::error::Release notes missing in CHANGELOG.md');
|
|
33
|
+
console.error(`Expected CHANGELOG.md to contain a heading like: ${expectedHeadingPrefix}YYYY-MM-DD`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(`✅ CHANGELOG.md contains release heading for v${version}`);
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
6
|
-
const esmDir = path.join(projectRoot, 'dist', 'esm');
|
|
7
|
-
|
|
8
|
-
const EXTENSIONS = new Set(['.js', '.json', '.node']);
|
|
9
|
-
|
|
10
|
-
function withJsExtension(specifier) {
|
|
11
|
-
if (!specifier.startsWith('.')) return specifier;
|
|
12
|
-
|
|
13
|
-
// Split off query/hash if ever present.
|
|
14
|
-
const match = /^(.*?)([?#].*)?$/.exec(specifier);
|
|
15
|
-
const base = match?.[1] ?? specifier;
|
|
16
|
-
const suffix = match?.[2] ?? '';
|
|
17
|
-
|
|
18
|
-
if (base.endsWith('/')) return specifier;
|
|
19
|
-
|
|
20
|
-
const ext = path.posix.extname(base);
|
|
21
|
-
if (EXTENSIONS.has(ext)) return specifier;
|
|
22
|
-
|
|
23
|
-
return `${base}.js${suffix}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function rewriteFile(contents) {
|
|
27
|
-
let changed = false;
|
|
28
|
-
|
|
29
|
-
// Rewrite: export * from '...'
|
|
30
|
-
contents = contents.replace(
|
|
31
|
-
/(\bexport\s+\*\s+from\s+)(['"])([^'"]+)(\2)/g,
|
|
32
|
-
(full, prefix, quote, spec, suffixQuote) => {
|
|
33
|
-
const next = withJsExtension(spec);
|
|
34
|
-
if (next === spec) return full;
|
|
35
|
-
changed = true;
|
|
36
|
-
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
37
|
-
},
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Rewrite: export { ... } from '...'
|
|
41
|
-
contents = contents.replace(
|
|
42
|
-
/(\bexport\s+\{[^}]*\}\s+from\s+)(['"])([^'"]+)(\2)/g,
|
|
43
|
-
(full, prefix, quote, spec, suffixQuote) => {
|
|
44
|
-
const next = withJsExtension(spec);
|
|
45
|
-
if (next === spec) return full;
|
|
46
|
-
changed = true;
|
|
47
|
-
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
// Rewrite: import ... from '...'
|
|
52
|
-
contents = contents.replace(
|
|
53
|
-
/(\bimport\s+[^;\n]+\s+from\s+)(['"])([^'"]+)(\2)/g,
|
|
54
|
-
(full, prefix, quote, spec, suffixQuote) => {
|
|
55
|
-
const next = withJsExtension(spec);
|
|
56
|
-
if (next === spec) return full;
|
|
57
|
-
changed = true;
|
|
58
|
-
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
59
|
-
},
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// Rewrite: import '...'
|
|
63
|
-
contents = contents.replace(
|
|
64
|
-
/(\bimport\s+)(['"])([^'"]+)(\2)/g,
|
|
65
|
-
(full, prefix, quote, spec, suffixQuote) => {
|
|
66
|
-
const next = withJsExtension(spec);
|
|
67
|
-
if (next === spec) return full;
|
|
68
|
-
changed = true;
|
|
69
|
-
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
return { contents, changed };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function* walk(dir) {
|
|
77
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
78
|
-
for (const entry of entries) {
|
|
79
|
-
const fullPath = path.join(dir, entry.name);
|
|
80
|
-
if (entry.isDirectory()) {
|
|
81
|
-
yield* walk(fullPath);
|
|
82
|
-
} else {
|
|
83
|
-
yield fullPath;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function main() {
|
|
89
|
-
try {
|
|
90
|
-
await fs.access(esmDir);
|
|
91
|
-
} catch {
|
|
92
|
-
console.error(`dist/esm not found: ${esmDir}`);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let processed = 0;
|
|
97
|
-
let rewritten = 0;
|
|
98
|
-
|
|
99
|
-
for await (const filePath of walk(esmDir)) {
|
|
100
|
-
if (!filePath.endsWith('.js')) continue;
|
|
101
|
-
|
|
102
|
-
const original = await fs.readFile(filePath, 'utf8');
|
|
103
|
-
const { contents, changed } = rewriteFile(original);
|
|
104
|
-
|
|
105
|
-
processed++;
|
|
106
|
-
if (changed) {
|
|
107
|
-
await fs.writeFile(filePath, contents, 'utf8');
|
|
108
|
-
rewritten++;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
console.log(`fix-esm-imports: processed ${processed} file(s), rewrote ${rewritten} file(s)`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await main();
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
6
|
+
const esmDir = path.join(projectRoot, 'dist', 'esm');
|
|
7
|
+
|
|
8
|
+
const EXTENSIONS = new Set(['.js', '.json', '.node']);
|
|
9
|
+
|
|
10
|
+
function withJsExtension(specifier) {
|
|
11
|
+
if (!specifier.startsWith('.')) return specifier;
|
|
12
|
+
|
|
13
|
+
// Split off query/hash if ever present.
|
|
14
|
+
const match = /^(.*?)([?#].*)?$/.exec(specifier);
|
|
15
|
+
const base = match?.[1] ?? specifier;
|
|
16
|
+
const suffix = match?.[2] ?? '';
|
|
17
|
+
|
|
18
|
+
if (base.endsWith('/')) return specifier;
|
|
19
|
+
|
|
20
|
+
const ext = path.posix.extname(base);
|
|
21
|
+
if (EXTENSIONS.has(ext)) return specifier;
|
|
22
|
+
|
|
23
|
+
return `${base}.js${suffix}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function rewriteFile(contents) {
|
|
27
|
+
let changed = false;
|
|
28
|
+
|
|
29
|
+
// Rewrite: export * from '...'
|
|
30
|
+
contents = contents.replace(
|
|
31
|
+
/(\bexport\s+\*\s+from\s+)(['"])([^'"]+)(\2)/g,
|
|
32
|
+
(full, prefix, quote, spec, suffixQuote) => {
|
|
33
|
+
const next = withJsExtension(spec);
|
|
34
|
+
if (next === spec) return full;
|
|
35
|
+
changed = true;
|
|
36
|
+
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Rewrite: export { ... } from '...'
|
|
41
|
+
contents = contents.replace(
|
|
42
|
+
/(\bexport\s+\{[^}]*\}\s+from\s+)(['"])([^'"]+)(\2)/g,
|
|
43
|
+
(full, prefix, quote, spec, suffixQuote) => {
|
|
44
|
+
const next = withJsExtension(spec);
|
|
45
|
+
if (next === spec) return full;
|
|
46
|
+
changed = true;
|
|
47
|
+
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Rewrite: import ... from '...'
|
|
52
|
+
contents = contents.replace(
|
|
53
|
+
/(\bimport\s+[^;\n]+\s+from\s+)(['"])([^'"]+)(\2)/g,
|
|
54
|
+
(full, prefix, quote, spec, suffixQuote) => {
|
|
55
|
+
const next = withJsExtension(spec);
|
|
56
|
+
if (next === spec) return full;
|
|
57
|
+
changed = true;
|
|
58
|
+
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Rewrite: import '...'
|
|
63
|
+
contents = contents.replace(
|
|
64
|
+
/(\bimport\s+)(['"])([^'"]+)(\2)/g,
|
|
65
|
+
(full, prefix, quote, spec, suffixQuote) => {
|
|
66
|
+
const next = withJsExtension(spec);
|
|
67
|
+
if (next === spec) return full;
|
|
68
|
+
changed = true;
|
|
69
|
+
return `${prefix}${quote}${next}${suffixQuote}`;
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return { contents, changed };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function* walk(dir) {
|
|
77
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
const fullPath = path.join(dir, entry.name);
|
|
80
|
+
if (entry.isDirectory()) {
|
|
81
|
+
yield* walk(fullPath);
|
|
82
|
+
} else {
|
|
83
|
+
yield fullPath;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function main() {
|
|
89
|
+
try {
|
|
90
|
+
await fs.access(esmDir);
|
|
91
|
+
} catch {
|
|
92
|
+
console.error(`dist/esm not found: ${esmDir}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let processed = 0;
|
|
97
|
+
let rewritten = 0;
|
|
98
|
+
|
|
99
|
+
for await (const filePath of walk(esmDir)) {
|
|
100
|
+
if (!filePath.endsWith('.js')) continue;
|
|
101
|
+
|
|
102
|
+
const original = await fs.readFile(filePath, 'utf8');
|
|
103
|
+
const { contents, changed } = rewriteFile(original);
|
|
104
|
+
|
|
105
|
+
processed++;
|
|
106
|
+
if (changed) {
|
|
107
|
+
await fs.writeFile(filePath, contents, 'utf8');
|
|
108
|
+
rewritten++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log(`fix-esm-imports: processed ${processed} file(s), rewrote ${rewritten} file(s)`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
await main();
|