@shanyucoder/flowgrid 0.1.2 → 0.1.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/bin/flowgrid.mjs +23 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ pnpm 10+ cần `--allow-build` khi cài **từ GitHub** (build TypeScript lúc c
|
|
|
91
91
|
| --- | --- |
|
|
92
92
|
| **Linux / macOS** | Chạy `pnpm setup` nếu shell báo thiếu bin; thường là `~/.local/share/pnpm`. |
|
|
93
93
|
| **WSL** | Giống Linux — dùng Node/pnpm **trong WSL**, không trộn với Node cài trên Windows host trừ khi cố ý. |
|
|
94
|
-
| **Windows (PowerShell, CMD, Windows Terminal)** | Chạy **`pnpm setup`** một lần (ghi PATH user), **đóng và mở lại** terminal; kiểm tra: `where.exe flowgrid`
|
|
94
|
+
| **Windows (PowerShell, CMD, Windows Terminal)** | Chạy **`pnpm setup`** một lần (ghi PATH user), **đóng và mở lại** terminal; kiểm tra: `where.exe flowgrid` · `flowgrid --version` (hoặc `flowgrid version`). Cần **Node ≥ 24** — nếu im lặng, chạy `node -v` rồi `pnpm add -g @shanyucoder/flowgrid@latest` sau bản **≥ 0.1.3** (fix CLI Windows). |
|
|
95
95
|
|
|
96
96
|
**WSL / Git Bash** có thể dùng lệnh pnpm ở trên; **không** bắt buộc `install.sh` nếu đã cài global qua pnpm.
|
|
97
97
|
|
package/bin/flowgrid.mjs
CHANGED
|
@@ -21,6 +21,27 @@ import {
|
|
|
21
21
|
promptHubRoot,
|
|
22
22
|
} from './lib/init-scaffold.mjs';
|
|
23
23
|
|
|
24
|
+
function packageRootFromMeta(metaUrl) {
|
|
25
|
+
return path.resolve(path.dirname(fileURLToPath(metaUrl)), '..');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** pnpm/npm global shims on Windows may differ in path casing from import.meta.url */
|
|
29
|
+
function isCliEntry(metaUrl) {
|
|
30
|
+
const invoked = process.argv[1];
|
|
31
|
+
if (!invoked) return false;
|
|
32
|
+
const entry = path.resolve(fileURLToPath(metaUrl));
|
|
33
|
+
const script = path.resolve(invoked);
|
|
34
|
+
if (script === entry) return true;
|
|
35
|
+
if (process.platform === 'win32' && script.toLowerCase() === entry.toLowerCase()) return true;
|
|
36
|
+
if (process.platform === 'win32') {
|
|
37
|
+
return (
|
|
38
|
+
path.basename(script).toLowerCase() === 'flowgrid.mjs' &&
|
|
39
|
+
path.basename(entry).toLowerCase() === 'flowgrid.mjs'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
24
45
|
function assertNodeVersion() {
|
|
25
46
|
const major = Number(process.versions.node.split('.')[0]);
|
|
26
47
|
if (!Number.isFinite(major) || major < 24) {
|
|
@@ -35,7 +56,7 @@ export async function main() {
|
|
|
35
56
|
assertNodeVersion();
|
|
36
57
|
const args = process.argv.slice(2);
|
|
37
58
|
if (args.includes('version') || args.includes('-v') || args.includes('--version')) {
|
|
38
|
-
const pkgPath = path.
|
|
59
|
+
const pkgPath = path.join(packageRootFromMeta(import.meta.url), 'package.json');
|
|
39
60
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
40
61
|
console.log(`FlowGrid v${pkg.version}`);
|
|
41
62
|
return;
|
|
@@ -917,11 +938,7 @@ export async function main() {
|
|
|
917
938
|
outro(pc.green("Success! FlowGrid is initialized for your project."));
|
|
918
939
|
}
|
|
919
940
|
|
|
920
|
-
|
|
921
|
-
process.argv[1] &&
|
|
922
|
-
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
923
|
-
|
|
924
|
-
if (isDirectCli) {
|
|
941
|
+
if (isCliEntry(import.meta.url)) {
|
|
925
942
|
main().catch((err) => {
|
|
926
943
|
console.error(pc.red(err.message));
|
|
927
944
|
process.exit(1);
|