@jskit-ai/create-app 0.1.25 → 0.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/create-app",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Scaffold minimal JSKIT app shells.",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # Re-link installed @jskit-ai packages in node_modules to a local jskit-ai monorepo checkout.
2
+ # Link all local @jskit-ai packages from a jskit-ai monorepo checkout into node_modules.
3
3
  # Run this AFTER `npm install` when you want live local development without publishing packages.
4
4
  #
5
5
  # Usage:
@@ -63,39 +63,76 @@ if ! is_valid_jskit_repo_root "$JSKIT_REPO_ROOT"; then
63
63
  exit 1
64
64
  fi
65
65
 
66
- resolve_source_dir() {
67
- local package_dir_name="$1"
68
- case "$package_dir_name" in
69
- config-eslint|create-app|jskit-cli|jskit-catalog)
70
- echo "$JSKIT_REPO_ROOT/tooling/$package_dir_name"
71
- ;;
72
- *)
73
- echo "$JSKIT_REPO_ROOT/packages/$package_dir_name"
74
- ;;
75
- esac
66
+ discover_local_package_map() {
67
+ node - "$JSKIT_REPO_ROOT" <<'NODE'
68
+ const fs = require("node:fs");
69
+ const path = require("node:path");
70
+
71
+ const repoRoot = process.argv[2];
72
+ const parentDirectories = [
73
+ path.join(repoRoot, "packages"),
74
+ path.join(repoRoot, "tooling")
75
+ ];
76
+ const packageMap = new Map();
77
+
78
+ for (const parentDirectory of parentDirectories) {
79
+ if (!fs.existsSync(parentDirectory) || !fs.statSync(parentDirectory).isDirectory()) {
80
+ continue;
81
+ }
82
+
83
+ for (const entry of fs.readdirSync(parentDirectory, { withFileTypes: true })) {
84
+ if (!entry.isDirectory() || entry.name.startsWith(".")) {
85
+ continue;
86
+ }
87
+
88
+ const packageRoot = path.join(parentDirectory, entry.name);
89
+ const packageJsonPath = path.join(packageRoot, "package.json");
90
+ const descriptorPath = path.join(packageRoot, "package.descriptor.mjs");
91
+ if (!fs.existsSync(packageJsonPath) || !fs.existsSync(descriptorPath)) {
92
+ continue;
93
+ }
94
+
95
+ let packageJson = {};
96
+ try {
97
+ packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
98
+ } catch {
99
+ continue;
100
+ }
101
+
102
+ const packageId = String(packageJson?.name || "").trim();
103
+ if (!packageId.startsWith("@jskit-ai/")) {
104
+ continue;
105
+ }
106
+ const packageDirName = packageId.slice("@jskit-ai/".length);
107
+ if (!packageDirName || packageDirName.includes("/")) {
108
+ continue;
109
+ }
110
+
111
+ if (!packageMap.has(packageDirName)) {
112
+ packageMap.set(packageDirName, packageRoot);
113
+ }
114
+ }
76
115
  }
77
116
 
78
- linked_count=0
79
- skipped_count=0
80
-
81
- for installed_path in "$SCOPE_DIR"/*; do
82
- if [[ ! -e "$installed_path" && ! -L "$installed_path" ]]; then
83
- continue
84
- fi
117
+ for (const [packageDirName, packageRoot] of packageMap.entries()) {
118
+ process.stdout.write(`${packageDirName}\t${packageRoot}\n`);
119
+ }
120
+ NODE
121
+ }
85
122
 
86
- package_dir_name="$(basename "$installed_path")"
87
- source_dir="$(resolve_source_dir "$package_dir_name")"
123
+ linked_count=0
88
124
 
89
- if [[ ! -f "$source_dir/package.json" ]]; then
90
- echo "[link-local] skip @jskit-ai/$package_dir_name (no local source at $source_dir)"
91
- skipped_count=$((skipped_count + 1))
125
+ mkdir -p "$SCOPE_DIR"
126
+ while IFS=$'\t' read -r package_dir_name source_dir; do
127
+ if [[ -z "$package_dir_name" || -z "$source_dir" ]]; then
92
128
  continue
93
129
  fi
94
130
 
95
- rm -rf "$installed_path"
96
- ln -s "$source_dir" "$installed_path"
131
+ target_path="$SCOPE_DIR/$package_dir_name"
132
+ rm -rf "$target_path"
133
+ ln -s "$source_dir" "$target_path"
97
134
  echo "[link-local] linked @jskit-ai/$package_dir_name -> $source_dir"
98
135
  linked_count=$((linked_count + 1))
99
- done
136
+ done < <(discover_local_package_map)
100
137
 
101
- echo "[link-local] done. linked=$linked_count skipped=$skipped_count"
138
+ echo "[link-local] done. linked=$linked_count"