@timeax/scaffold 0.0.11 → 0.0.13
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/.vscode/settings.json +0 -1
- package/dist/cli.cjs +16 -22
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +16 -22
- package/dist/cli.mjs.map +1 -1
- package/package.json +4 -2
- package/scripts/postpublish.mjs +16 -6
- package/src/core/watcher.ts +29 -32
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timeax/scaffold",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"description": "A CLI tool that scaffolds project file structures based on a user-defined, type-safe configuration file.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"scaffold"
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
"types": "dist/index.d.ts",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
25
26
|
"import": "./dist/index.mjs",
|
|
26
27
|
"require": "./dist/index.cjs"
|
|
27
28
|
},
|
|
28
29
|
"./ast": {
|
|
30
|
+
"types": "./dist/ast.d.ts",
|
|
29
31
|
"import": "./dist/ast.mjs",
|
|
30
32
|
"require": "./dist/ast.cjs"
|
|
31
33
|
}
|
|
@@ -55,4 +57,4 @@
|
|
|
55
57
|
"esbuild": "^0.27.0",
|
|
56
58
|
"minimatch": "^10.1.1"
|
|
57
59
|
}
|
|
58
|
-
}
|
|
60
|
+
}
|
package/scripts/postpublish.mjs
CHANGED
|
@@ -11,10 +11,11 @@ function incrementPatch(version) {
|
|
|
11
11
|
throw new Error(`[postpublish] Unsupported version format: "${version}"`);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let [majorRaw, minorRaw, patchRaw] = parts;
|
|
15
|
+
|
|
16
|
+
let major = Number(majorRaw);
|
|
17
|
+
let minor = Number(minorRaw);
|
|
18
|
+
let patch = Number(patchRaw);
|
|
18
19
|
|
|
19
20
|
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) {
|
|
20
21
|
throw new Error(
|
|
@@ -22,8 +23,17 @@ function incrementPatch(version) {
|
|
|
22
23
|
);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
// Single-digit patch rule:
|
|
27
|
+
// - If patch >= 9, roll into next minor and reset patch to 0.
|
|
28
|
+
// - Otherwise, just increment patch.
|
|
29
|
+
if (patch >= 9) {
|
|
30
|
+
patch = 0;
|
|
31
|
+
minor += 1;
|
|
32
|
+
} else {
|
|
33
|
+
patch += 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return `${major}.${minor}.${patch}`;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
function main() {
|
package/src/core/watcher.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import chokidar from 'chokidar';
|
|
5
|
-
import {runOnce, type RunOptions} from './runner';
|
|
6
|
-
import {defaultLogger, type Logger} from '../util/logger';
|
|
7
|
-
import {SCAFFOLD_ROOT_DIR} from '..';
|
|
5
|
+
import { runOnce, type RunOptions } from './runner';
|
|
6
|
+
import { defaultLogger, type Logger } from '../util/logger';
|
|
7
|
+
import { SCAFFOLD_ROOT_DIR } from '..';
|
|
8
8
|
|
|
9
9
|
export interface WatchOptions extends RunOptions {
|
|
10
10
|
/**
|
|
@@ -24,11 +24,11 @@ export interface WatchOptions extends RunOptions {
|
|
|
24
24
|
/**
|
|
25
25
|
* Watch the scaffold directory and re-run scaffold on changes.
|
|
26
26
|
*
|
|
27
|
-
* This watches
|
|
28
|
-
* -
|
|
29
|
-
*
|
|
27
|
+
* This watches the entire .scaffold folder and then filters events
|
|
28
|
+
* in-process to:
|
|
29
|
+
* - config.* files
|
|
30
|
+
* - *.txt / *.tss / *.stx
|
|
30
31
|
*
|
|
31
|
-
* CLI can call this when `--watch` is enabled.
|
|
32
32
|
* Any `format` options in RunOptions are passed straight through to `runOnce`,
|
|
33
33
|
* so formatting from config / CLI is applied on each re-run.
|
|
34
34
|
*/
|
|
@@ -60,7 +60,7 @@ export function watchScaffold(cwd: string, options: WatchOptions = {}): void {
|
|
|
60
60
|
// we already resolved scaffoldDir for watcher; pass it down
|
|
61
61
|
scaffoldDir,
|
|
62
62
|
});
|
|
63
|
-
logger.info('Scaffold run completed
|
|
63
|
+
logger.info('Scaffold run completed');
|
|
64
64
|
} catch (err) {
|
|
65
65
|
logger.error('Scaffold run failed:', err);
|
|
66
66
|
} finally {
|
|
@@ -77,32 +77,29 @@ export function watchScaffold(cwd: string, options: WatchOptions = {}): void {
|
|
|
77
77
|
timer = setTimeout(run, debounceMs);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
// Only react to config.* and structure files inside scaffoldDir
|
|
81
|
+
function isInteresting(filePath: string): boolean {
|
|
82
|
+
const rel = path.relative(scaffoldDir, filePath);
|
|
83
|
+
// Outside .scaffold or in parent → ignore
|
|
84
|
+
if (rel.startsWith('..')) return false;
|
|
85
|
+
|
|
86
|
+
const base = path.basename(filePath).toLowerCase();
|
|
87
|
+
// config.ts / config.js / config.mts / etc.
|
|
88
|
+
if (base.startsWith('config.')) return true;
|
|
89
|
+
|
|
90
|
+
const ext = path.extname(base);
|
|
91
|
+
return ext === '.txt' || ext === '.tss' || ext === '.stx';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const watcher = chokidar.watch(scaffoldDir, {
|
|
95
|
+
ignoreInitial: false,
|
|
96
|
+
persistent: true,
|
|
97
|
+
});
|
|
94
98
|
|
|
95
99
|
watcher
|
|
96
|
-
.on('
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
.on('change', (filePath) => {
|
|
101
|
-
logger.debug(`File changed: ${filePath}`);
|
|
102
|
-
scheduleRun();
|
|
103
|
-
})
|
|
104
|
-
.on('unlink', (filePath) => {
|
|
105
|
-
logger.debug(`File removed: ${filePath}`);
|
|
100
|
+
.on('all', (event, filePath) => {
|
|
101
|
+
if (!isInteresting(filePath)) return;
|
|
102
|
+
logger.debug(`Event ${event} on ${filePath}`);
|
|
106
103
|
scheduleRun();
|
|
107
104
|
})
|
|
108
105
|
.on('error', (error) => {
|