@coze-arch/cli 0.1.8-alpha.a87968 → 0.1.8-alpha.e237ba

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.
Files changed (33) hide show
  1. package/README.md +18 -0
  2. package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +1 -3
  3. package/lib/__templates__/native-static/.coze +2 -2
  4. package/lib/__templates__/nextjs/.coze +1 -1
  5. package/lib/__templates__/nextjs/README.md +18 -0
  6. package/lib/__templates__/nextjs/scripts/build.sh +1 -1
  7. package/lib/__templates__/nextjs/scripts/dev.sh +16 -41
  8. package/lib/__templates__/nextjs/scripts/local-workspace.cjs +302 -0
  9. package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +1 -3
  10. package/lib/__templates__/nextjs/scripts/prepare.sh +10 -2
  11. package/lib/__templates__/nextjs/scripts/validate.sh +11 -1
  12. package/lib/__templates__/nextjs/template.config.js +20 -6
  13. package/lib/__templates__/nuxt-vue/.coze +1 -1
  14. package/lib/__templates__/nuxt-vue/README.md +20 -2
  15. package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
  16. package/lib/__templates__/nuxt-vue/scripts/dev.sh +10 -4
  17. package/lib/__templates__/nuxt-vue/scripts/local-workspace.cjs +302 -0
  18. package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +1 -3
  19. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +10 -2
  20. package/lib/__templates__/nuxt-vue/scripts/validate.sh +11 -1
  21. package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +1 -3
  22. package/lib/__templates__/vite/.coze +1 -1
  23. package/lib/__templates__/vite/README.md +20 -0
  24. package/lib/__templates__/vite/scripts/build.sh +1 -1
  25. package/lib/__templates__/vite/scripts/dev.sh +10 -4
  26. package/lib/__templates__/vite/scripts/local-workspace.cjs +302 -0
  27. package/lib/__templates__/vite/scripts/prepare-node-modules.sh +1 -3
  28. package/lib/__templates__/vite/scripts/prepare.sh +10 -2
  29. package/lib/__templates__/vite/scripts/validate.sh +7 -1
  30. package/lib/__templates__/vite/template.config.js +20 -6
  31. package/lib/cli.js +365 -184
  32. package/package.json +2 -1
  33. package/lib/__templates__/nextjs/scripts/prepare-next-dev-output.sh +0 -122
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.1.8-alpha.a87968",
3
+ "version": "0.1.8-alpha.e237ba",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  "test:all": "bash scripts/test-coverage.sh",
35
35
  "test:cov": "vitest --run --passWithNoTests --coverage",
36
36
  "test:e2e": "NODE_ENV=test bash scripts/e2e.sh",
37
+ "test:integration:web": "node --test __tests__/integration/local-workspace.test.cjs",
37
38
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
38
39
  "test:perf:compare": "bash scripts/compare-perf.sh",
39
40
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
@@ -1,122 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Keep Next development output off Coze Drive without moving production output.
3
- set -euo pipefail
4
-
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
6
- if [ "$(basename "$(dirname "$SCRIPT_DIR")")" = ".cozeproj" ]; then
7
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
8
- else
9
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
10
- fi
11
-
12
- DRIVE_ROOT="${COZE_DRIVE_ROOT:-/Coze/Drive}"
13
- if [ -d "$DRIVE_ROOT" ]; then
14
- DRIVE_ROOT="$(cd "$DRIVE_ROOT" && pwd -P)"
15
- else
16
- DRIVE_ROOT="${DRIVE_ROOT%/}"
17
- fi
18
- case "$PROJECT_ROOT" in
19
- "$DRIVE_ROOT"|"$DRIVE_ROOT"/*) ;;
20
- *) exit 0 ;;
21
- esac
22
-
23
- # Next writes every on-demand development build into .next/dev. On Coze Drive each of
24
- # those writes goes through the sync daemon, so only that subtree moves to local disk.
25
- # Production output stays in the project directory, which keeps `next build` and
26
- # deployment unchanged.
27
- #
28
- # One local directory per project, shared with prepare-node-modules.sh: node_modules and
29
- # this cache sit side by side under WORK_DIR. The caches subdirectory is the slot that
30
- # script reserves for output that must survive an install, so nothing here is cleaned up
31
- # behind our back. PROJECT_ID has to stay identical to the one it computes.
32
- NM_ROOT="/tmp/nm"
33
- PROJECT_ID="$(basename "$PROJECT_ROOT")-$(printf '%s' "$PROJECT_ROOT" | cksum | awk '{print $1}')"
34
- WORK_DIR="$NM_ROOT/$PROJECT_ID"
35
- NEXT_ROOT="$PROJECT_ROOT/.next"
36
- NEXT_DEV="$NEXT_ROOT/dev"
37
- LEGACY_NEXT_ROOT="$WORK_DIR/.next"
38
- LOCAL_NEXT_DEV="$WORK_DIR/caches/next-dev"
39
-
40
- case "$LOCAL_NEXT_DEV" in
41
- "$DRIVE_ROOT"|"$DRIVE_ROOT"/*)
42
- echo "[next] local development output must not be on Coze Drive: $LOCAL_NEXT_DEV" >&2
43
- exit 1
44
- ;;
45
- esac
46
-
47
- # Coze Drive sync does not preserve symlinks: a synced copy of a link arrives as a
48
- # regular file holding the link target. Recognize the links this scheme creates so a
49
- # project that came back from sync repairs itself instead of failing to start.
50
- is_flattened_managed_link() {
51
- local candidate="$1" content=""
52
- [ -f "$candidate" ] || return 1
53
- [ ! -L "$candidate" ] || return 1
54
- [ "$(wc -c < "$candidate")" -le 4096 ] || return 1
55
- content="$(tr -d '\r\n' < "$candidate")"
56
- case "$content" in
57
- "$NM_ROOT"/*) return 0 ;;
58
- esac
59
- return 1
60
- }
61
-
62
- # Earlier versions linked the whole .next directory. Bring any production build made
63
- # back then into the project; from here on only .next/dev is redirected.
64
- restore_legacy_next_root() {
65
- local entry
66
- rm -f "$NEXT_ROOT"
67
- mkdir -p "$NEXT_ROOT"
68
- if [ -d "$LEGACY_NEXT_ROOT" ]; then
69
- while IFS= read -r -d '' entry; do
70
- mv "$entry" "$NEXT_ROOT/"
71
- done < <(find -P "$LEGACY_NEXT_ROOT" -mindepth 1 -maxdepth 1 -print0)
72
- rmdir "$LEGACY_NEXT_ROOT" 2>/dev/null || true
73
- fi
74
- }
75
-
76
- if [ -L "$NEXT_ROOT" ]; then
77
- case "$(readlink "$NEXT_ROOT")" in
78
- "$NM_ROOT"/*)
79
- echo "[next] Restoring legacy .next output to the project directory."
80
- restore_legacy_next_root
81
- ;;
82
- *)
83
- echo "[next] refusing to replace unmanaged .next symlink: $NEXT_ROOT" >&2
84
- exit 1
85
- ;;
86
- esac
87
- elif is_flattened_managed_link "$NEXT_ROOT"; then
88
- echo "[next] Recovering .next flattened by Coze Drive sync."
89
- restore_legacy_next_root
90
- elif [ -e "$NEXT_ROOT" ] && [ ! -d "$NEXT_ROOT" ]; then
91
- echo "[next] refusing to replace non-directory Next output: $NEXT_ROOT" >&2
92
- exit 1
93
- fi
94
-
95
- mkdir -p "$NEXT_ROOT" "$LOCAL_NEXT_DEV"
96
-
97
- if [ -L "$NEXT_DEV" ]; then
98
- if [ "$(readlink "$NEXT_DEV")" = "$LOCAL_NEXT_DEV" ]; then
99
- exit 0
100
- fi
101
- case "$(readlink "$NEXT_DEV")" in
102
- "$NM_ROOT"/*) rm "$NEXT_DEV" ;;
103
- *)
104
- echo "[next] refusing to replace unmanaged .next/dev symlink: $NEXT_DEV" >&2
105
- exit 1
106
- ;;
107
- esac
108
- elif [ -e "$NEXT_DEV" ]; then
109
- # .next/dev holds development output only, and Next regenerates it on demand.
110
- rm -rf "$NEXT_DEV"
111
- fi
112
-
113
- # A second dev start can win the race between the removal above and this link.
114
- if ! ln -s "$LOCAL_NEXT_DEV" "$NEXT_DEV" 2>/dev/null; then
115
- if [ -L "$NEXT_DEV" ] && [ "$(readlink "$NEXT_DEV")" = "$LOCAL_NEXT_DEV" ]; then
116
- exit 0
117
- fi
118
- echo "[next] failed to link development output: $NEXT_DEV" >&2
119
- exit 1
120
- fi
121
-
122
- echo "[next] Development output linked to $LOCAL_NEXT_DEV"