@coze-arch/cli 0.1.4-alpha.fb90f3 → 0.1.5-alpha.2e246f
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.ps1 +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +3 -3
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.ps1 +3 -3
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +0 -2
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +3 -3
- package/lib/__templates__/expo/client/components/Screen.tsx +25 -65
- package/lib/__templates__/expo/client/heroui/components/toast/toast.tsx +2 -6
- package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts +1 -1
- package/lib/__templates__/nextjs/.babelrc +15 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -11
- package/lib/__templates__/nextjs/next.config.ts +0 -10
- package/lib/__templates__/nextjs/package.json +6 -3
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1071 -136
- package/lib/__templates__/nextjs/scripts/build.ps1 +1 -1
- package/lib/__templates__/nextjs/scripts/build.sh +2 -3
- package/lib/__templates__/nextjs/scripts/dev.sh +3 -6
- package/lib/__templates__/nextjs/scripts/prepare.sh +4 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +4 -0
- 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.ps1 +1 -4
- package/lib/__templates__/vite/scripts/build.sh +1 -1
- package/lib/__templates__/vite/scripts/dev.ps1 +23 -7
- package/lib/__templates__/vite/scripts/dev.sh +0 -2
- package/lib/__templates__/vite/scripts/ensure-deps.ps1 +33 -0
- package/lib/__templates__/vite/scripts/prepare.ps1 +1 -6
- package/lib/__templates__/vite/scripts/prepare.sh +4 -1
- package/lib/__templates__/vite/template.config.js +59 -0
- package/lib/cli.js +19 -38
- package/package.json +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/nextjs/scripts/prepare-next-output.sh +0 -62
- package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/vite/scripts/prepare-node-modules.sh +0 -149
|
@@ -1,149 +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
|
-
NM_ROOT="/tmp/nm"
|
|
32
|
-
PROJECT_ID="$(basename "$PROJECT_ROOT")-$(printf '%s' "$PROJECT_ROOT" | cksum | awk '{print $1}')"
|
|
33
|
-
mkdir -p "$NM_ROOT"
|
|
34
|
-
WORK_DIR="$NM_ROOT/$PROJECT_ID"
|
|
35
|
-
case "$WORK_DIR" in
|
|
36
|
-
"$DRIVE_ROOT"|"$DRIVE_ROOT"/*)
|
|
37
|
-
echo "[node_modules] local dependency directory must not be on Coze Drive: $WORK_DIR" >&2
|
|
38
|
-
exit 1
|
|
39
|
-
;;
|
|
40
|
-
esac
|
|
41
|
-
|
|
42
|
-
LOCK_DIR="$NM_ROOT/$PROJECT_ID.lock"
|
|
43
|
-
while ! mkdir "$LOCK_DIR" 2>/dev/null; do
|
|
44
|
-
echo "[node_modules] Waiting for another dependency preparation for this project..."
|
|
45
|
-
sleep 1
|
|
46
|
-
done
|
|
47
|
-
trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
48
|
-
|
|
49
|
-
mkdir -p "$WORK_DIR"
|
|
50
|
-
|
|
51
|
-
# Mirror the project with symlinks. node_modules and managed compiler output
|
|
52
|
-
# stay real in WORK_DIR; workspace directories stay real there too.
|
|
53
|
-
mirror_root() {
|
|
54
|
-
local entry name
|
|
55
|
-
while IFS= read -r -d '' entry; do
|
|
56
|
-
name="$(basename "$entry")"
|
|
57
|
-
case "$name" in
|
|
58
|
-
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
59
|
-
client|server)
|
|
60
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
|
-
;;
|
|
62
|
-
esac
|
|
63
|
-
rm -rf "$entry"
|
|
64
|
-
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
65
|
-
|
|
66
|
-
while IFS= read -r -d '' entry; do
|
|
67
|
-
name="$(basename "$entry")"
|
|
68
|
-
case "$name" in
|
|
69
|
-
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
70
|
-
client|server)
|
|
71
|
-
[ -f "$entry/package.json" ] && continue
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
75
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
mirror_workspace() {
|
|
79
|
-
local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
|
|
80
|
-
local entry name
|
|
81
|
-
if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
|
|
82
|
-
rm -rf "$work_dir"
|
|
83
|
-
fi
|
|
84
|
-
mkdir -p "$work_dir"
|
|
85
|
-
|
|
86
|
-
while IFS= read -r -d '' entry; do
|
|
87
|
-
[ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
|
|
88
|
-
done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
89
|
-
|
|
90
|
-
while IFS= read -r -d '' entry; do
|
|
91
|
-
name="$(basename "$entry")"
|
|
92
|
-
[ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
|
|
93
|
-
done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
mirror_root
|
|
97
|
-
for workspace in client server; do
|
|
98
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
99
|
-
mirror_workspace "$workspace"
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
104
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
106
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
110
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
111
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
116
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
117
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
118
|
-
chmod 0644 "$temporary_lockfile"
|
|
119
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
|
-
link_node_modules() {
|
|
123
|
-
local source_dir="$1" target_dir="$2"
|
|
124
|
-
local current=""
|
|
125
|
-
mkdir -p "$target_dir"
|
|
126
|
-
if [ -L "$source_dir/node_modules" ]; then
|
|
127
|
-
current="$(readlink "$source_dir/node_modules")"
|
|
128
|
-
case "$current" in
|
|
129
|
-
"$NM_ROOT"/*/node_modules|"$NM_ROOT"/*/*/node_modules) ;;
|
|
130
|
-
*)
|
|
131
|
-
echo "[node_modules] refusing to replace unmanaged symlink: $source_dir/node_modules" >&2
|
|
132
|
-
exit 1
|
|
133
|
-
;;
|
|
134
|
-
esac
|
|
135
|
-
rm "$source_dir/node_modules"
|
|
136
|
-
elif [ -e "$source_dir/node_modules" ]; then
|
|
137
|
-
rm -rf "$source_dir/node_modules"
|
|
138
|
-
fi
|
|
139
|
-
ln -s "$target_dir" "$source_dir/node_modules"
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
143
|
-
for workspace in client server; do
|
|
144
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
145
|
-
link_node_modules "$PROJECT_ROOT/$workspace" "$WORK_DIR/$workspace/node_modules"
|
|
146
|
-
fi
|
|
147
|
-
done
|
|
148
|
-
|
|
149
|
-
echo "[node_modules] Dependencies ready"
|