@coze-arch/cli 0.1.3-alpha.6f25e6 → 0.1.3-alpha.cb26ca
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/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +3 -3
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +3 -3
- package/lib/__templates__/nextjs/package.json +6 -1
- package/lib/__templates__/nextjs/pnpm-lock.yaml +59 -54
- package/lib/__templates__/nextjs/scripts/build.sh +1 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +0 -2
- package/lib/__templates__/nextjs/scripts/prepare.sh +4 -1
- package/lib/__templates__/nextjs/src/server.ts +1 -1
- package/lib/__templates__/nextjs/template.config.js +59 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +0 -2
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +4 -1
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +2 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +1 -3
- package/lib/__templates__/vite/scripts/build.sh +1 -1
- package/lib/__templates__/vite/scripts/dev.sh +0 -2
- package/lib/__templates__/vite/scripts/prepare.sh +4 -1
- package/lib/__templates__/vite/template.config.js +59 -0
- package/lib/cli.js +12 -34
- package/package.json +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +0 -142
- package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +0 -142
- package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +0 -142
- package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +0 -142
- package/lib/__templates__/vite/scripts/prepare-node-modules.sh +0 -142
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Install dependencies on local disk and expose them to the source tree by symlink.
|
|
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
|
-
command -v pnpm >/dev/null 2>&1 || {
|
|
13
|
-
echo "[node_modules] pnpm is required" >&2
|
|
14
|
-
exit 1
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
DRIVE_ROOT="${COZE_DRIVE_ROOT:-/Coze/Drive}"
|
|
18
|
-
if [ -d "$DRIVE_ROOT" ]; then
|
|
19
|
-
DRIVE_ROOT="$(cd "$DRIVE_ROOT" && pwd -P)"
|
|
20
|
-
else
|
|
21
|
-
DRIVE_ROOT="${DRIVE_ROOT%/}"
|
|
22
|
-
fi
|
|
23
|
-
case "$PROJECT_ROOT" in
|
|
24
|
-
"$DRIVE_ROOT"|"$DRIVE_ROOT"/*) ;;
|
|
25
|
-
*)
|
|
26
|
-
(cd "$PROJECT_ROOT" && pnpm install "$@")
|
|
27
|
-
exit 0
|
|
28
|
-
;;
|
|
29
|
-
esac
|
|
30
|
-
|
|
31
|
-
COZE_ROOT="${COZE_DIR_PATH:-${HOME}/Coze/tmp}"
|
|
32
|
-
PROJECT_ID="$(basename "$PROJECT_ROOT")-$(printf '%s' "$PROJECT_ROOT" | cksum | awk '{print $1}')"
|
|
33
|
-
mkdir -p "$COZE_ROOT/nm"
|
|
34
|
-
COZE_ROOT="$(cd "$COZE_ROOT" && pwd -P)"
|
|
35
|
-
WORK_DIR="$COZE_ROOT/nm/$PROJECT_ID"
|
|
36
|
-
mkdir -p "$WORK_DIR"
|
|
37
|
-
case "$WORK_DIR" in
|
|
38
|
-
"$DRIVE_ROOT"|"$DRIVE_ROOT"/*)
|
|
39
|
-
echo "[node_modules] local dependency directory must not be on Coze Drive: $WORK_DIR" >&2
|
|
40
|
-
exit 1
|
|
41
|
-
;;
|
|
42
|
-
esac
|
|
43
|
-
|
|
44
|
-
# Mirror the project with symlinks. node_modules stays real in WORK_DIR;
|
|
45
|
-
# workspace directories stay real too, so pnpm never writes them to Drive.
|
|
46
|
-
mirror_root() {
|
|
47
|
-
local entry name
|
|
48
|
-
while IFS= read -r -d '' entry; do
|
|
49
|
-
name="$(basename "$entry")"
|
|
50
|
-
case "$name" in
|
|
51
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
52
|
-
client|server)
|
|
53
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
54
|
-
;;
|
|
55
|
-
esac
|
|
56
|
-
rm -rf "$entry"
|
|
57
|
-
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
58
|
-
|
|
59
|
-
while IFS= read -r -d '' entry; do
|
|
60
|
-
name="$(basename "$entry")"
|
|
61
|
-
case "$name" in
|
|
62
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
63
|
-
client|server)
|
|
64
|
-
[ -f "$entry/package.json" ] && continue
|
|
65
|
-
;;
|
|
66
|
-
esac
|
|
67
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
68
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
mirror_workspace() {
|
|
72
|
-
local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
|
|
73
|
-
local entry name
|
|
74
|
-
if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
|
|
75
|
-
rm -rf "$work_dir"
|
|
76
|
-
fi
|
|
77
|
-
mkdir -p "$work_dir"
|
|
78
|
-
|
|
79
|
-
while IFS= read -r -d '' entry; do
|
|
80
|
-
[ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
|
|
81
|
-
done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
82
|
-
|
|
83
|
-
while IFS= read -r -d '' entry; do
|
|
84
|
-
name="$(basename "$entry")"
|
|
85
|
-
[ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
|
|
86
|
-
done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
mirror_root
|
|
90
|
-
for workspace in client server; do
|
|
91
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
92
|
-
mirror_workspace "$workspace"
|
|
93
|
-
fi
|
|
94
|
-
done
|
|
95
|
-
|
|
96
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
97
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
98
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
99
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
100
|
-
fi
|
|
101
|
-
|
|
102
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
103
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
104
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
exit 1
|
|
106
|
-
fi
|
|
107
|
-
|
|
108
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
109
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
110
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
111
|
-
chmod 0644 "$temporary_lockfile"
|
|
112
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
link_node_modules() {
|
|
116
|
-
local source_dir="$1" target_dir="$2"
|
|
117
|
-
local current=""
|
|
118
|
-
mkdir -p "$target_dir"
|
|
119
|
-
if [ -L "$source_dir/node_modules" ]; then
|
|
120
|
-
current="$(readlink "$source_dir/node_modules")"
|
|
121
|
-
case "$current" in
|
|
122
|
-
"$COZE_ROOT"/nm/*/node_modules|"$COZE_ROOT"/nm/*/*/node_modules) ;;
|
|
123
|
-
*)
|
|
124
|
-
echo "[node_modules] refusing to replace unmanaged symlink: $source_dir/node_modules" >&2
|
|
125
|
-
exit 1
|
|
126
|
-
;;
|
|
127
|
-
esac
|
|
128
|
-
rm "$source_dir/node_modules"
|
|
129
|
-
elif [ -e "$source_dir/node_modules" ]; then
|
|
130
|
-
rm -rf "$source_dir/node_modules"
|
|
131
|
-
fi
|
|
132
|
-
ln -s "$target_dir" "$source_dir/node_modules"
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
136
|
-
for workspace in client server; do
|
|
137
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
138
|
-
link_node_modules "$PROJECT_ROOT/$workspace" "$WORK_DIR/$workspace/node_modules"
|
|
139
|
-
fi
|
|
140
|
-
done
|
|
141
|
-
|
|
142
|
-
echo "[node_modules] Dependencies ready"
|