@coze-arch/cli 0.0.1-alpha.c7a03c → 0.0.1-alpha.c9a2ba

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 (36) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +22 -16
  2. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
  3. package/lib/__templates__/expo/README.md +2 -2
  4. package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
  5. package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
  6. package/lib/__templates__/expo/client/app.config.ts +2 -2
  7. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  8. package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
  9. package/lib/__templates__/expo/client/constants/theme.ts +30 -375
  10. package/lib/__templates__/expo/client/eslint.config.mjs +20 -0
  11. package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
  12. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  13. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  14. package/lib/__templates__/expo/client/package.json +3 -1
  15. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1886 -2483
  16. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +20 -1
  17. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  18. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  19. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  20. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  21. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  22. package/lib/__templates__/expo/package.json +3 -0
  23. package/lib/__templates__/expo/patches/expo@54.0.32.patch +45 -0
  24. package/lib/__templates__/expo/pnpm-lock.yaml +1211 -2702
  25. package/lib/__templates__/expo/server/package.json +1 -1
  26. package/lib/__templates__/expo/server/src/index.ts +2 -1
  27. package/lib/__templates__/nextjs/.babelrc +15 -0
  28. package/lib/__templates__/nextjs/package.json +9 -1
  29. package/lib/__templates__/nextjs/pnpm-lock.yaml +2603 -1728
  30. package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
  31. package/lib/__templates__/nextjs/template.config.js +5 -5
  32. package/lib/__templates__/vite/package.json +6 -1
  33. package/lib/__templates__/vite/pnpm-lock.yaml +504 -982
  34. package/lib/__templates__/vite/template.config.js +6 -4
  35. package/lib/cli.js +819 -105
  36. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
1
  const names = require('./names')
2
+ const v5OnlyNames = require('./v5-only-names')
3
+ const v5OnlyNamesSet = new Set(v5OnlyNames)
2
4
 
3
5
  const DEFAULTS = {
4
6
  whitelist: names,
@@ -49,6 +51,10 @@ function getStringLiteralValue(attribute) {
49
51
  return null;
50
52
  }
51
53
 
54
+ const replacements = {
55
+ 'plus-circle': 'circle-plus',
56
+ }
57
+
52
58
  module.exports = {
53
59
  meta: {
54
60
  type: 'problem',
@@ -84,7 +90,7 @@ module.exports = {
84
90
  ],
85
91
  messages: {
86
92
  invalidName:
87
- '{{componentName}} 中不存在图标 {{name}},请更换为其他图标',
93
+ '{{componentName}} 中不存在图标 {{name}},{{suggestion}}',
88
94
  },
89
95
  },
90
96
 
@@ -146,6 +152,7 @@ module.exports = {
146
152
  data: {
147
153
  componentName,
148
154
  name: literal,
155
+ suggestion: getSuggestion(normalized, literal),
149
156
  },
150
157
  });
151
158
  }
@@ -153,3 +160,15 @@ module.exports = {
153
160
  };
154
161
  },
155
162
  };
163
+
164
+ function getSuggestion(name, originalName) {
165
+ if (replacements[name]) {
166
+ return `请更换为 ${replacements[name]}`
167
+ }
168
+
169
+ if (v5OnlyNamesSet.has(name)) {
170
+ return `${originalName} 只能和 FontAwesome5 组件一起使用`
171
+ }
172
+
173
+ return '请更换为其他图标'
174
+ }
@@ -0,0 +1,388 @@
1
+ const v5names = [
2
+ "acquisitions-incorporated",
3
+ "behance-square",
4
+ "dribbble-square",
5
+ "facebook-square",
6
+ "font-awesome-alt",
7
+ "font-awesome-flag",
8
+ "font-awesome-logo-full",
9
+ "git-square",
10
+ "github-square",
11
+ "google-plus-square",
12
+ "hacker-news-square",
13
+ "innosoft",
14
+ "instagram-square",
15
+ "js-square",
16
+ "lastfm-square",
17
+ "medium-m",
18
+ "odnoklassniki-square",
19
+ "penny-arcade",
20
+ "pied-piper-square",
21
+ "pinterest-square",
22
+ "reddit-square",
23
+ "slack-hash",
24
+ "snapchat-ghost",
25
+ "snapchat-square",
26
+ "steam-square",
27
+ "telegram-plane",
28
+ "tripadvisor",
29
+ "tumblr-square",
30
+ "twitter-square",
31
+ "viadeo-square",
32
+ "vimeo-square",
33
+ "whatsapp-square",
34
+ "xing-square",
35
+ "youtube-square",
36
+ "angry",
37
+ "arrow-alt-circle-down",
38
+ "arrow-alt-circle-left",
39
+ "arrow-alt-circle-right",
40
+ "arrow-alt-circle-up",
41
+ "calendar-alt",
42
+ "calendar-times",
43
+ "caret-square-down",
44
+ "caret-square-left",
45
+ "caret-square-right",
46
+ "caret-square-up",
47
+ "check-circle",
48
+ "check-square",
49
+ "comment-alt",
50
+ "dizzy",
51
+ "dot-circle",
52
+ "edit",
53
+ "file-alt",
54
+ "file-archive",
55
+ "flushed",
56
+ "frown-open",
57
+ "frown",
58
+ "grimace",
59
+ "grin-alt",
60
+ "grin-beam-sweat",
61
+ "grin-beam",
62
+ "grin-hearts",
63
+ "grin-squint-tears",
64
+ "grin-squint",
65
+ "grin-stars",
66
+ "grin-tears",
67
+ "grin-tongue-squint",
68
+ "grin-tongue-wink",
69
+ "grin-tongue",
70
+ "grin-wink",
71
+ "grin",
72
+ "hand-paper",
73
+ "hand-rock",
74
+ "hdd",
75
+ "kiss-beam",
76
+ "kiss-wink-heart",
77
+ "kiss",
78
+ "laugh-beam",
79
+ "laugh-squint",
80
+ "laugh-wink",
81
+ "laugh",
82
+ "list-alt",
83
+ "meh-blank",
84
+ "meh-rolling-eyes",
85
+ "meh",
86
+ "minus-square",
87
+ "money-bill-alt",
88
+ "pause-circle",
89
+ "play-circle",
90
+ "plus-square",
91
+ "question-circle",
92
+ "sad-cry",
93
+ "sad-tear",
94
+ "save",
95
+ "share-square",
96
+ "smile-beam",
97
+ "smile-wink",
98
+ "smile",
99
+ "sticky-note",
100
+ "stop-circle",
101
+ "surprise",
102
+ "times-circle",
103
+ "tired",
104
+ "trash-alt",
105
+ "user-circle",
106
+ "window-close",
107
+ "ad",
108
+ "adjust",
109
+ "air-freshener",
110
+ "allergies",
111
+ "ambulance",
112
+ "american-sign-language-interpreting",
113
+ "angle-double-down",
114
+ "angle-double-left",
115
+ "angle-double-right",
116
+ "angle-double-up",
117
+ "apple-alt",
118
+ "archive",
119
+ "arrow-circle-down",
120
+ "arrow-circle-left",
121
+ "arrow-circle-right",
122
+ "arrow-circle-up",
123
+ "arrows-alt-h",
124
+ "arrows-alt-v",
125
+ "arrows-alt",
126
+ "assistive-listening-systems",
127
+ "atlas",
128
+ "backspace",
129
+ "balance-scale-left",
130
+ "balance-scale-right",
131
+ "balance-scale",
132
+ "band-aid",
133
+ "baseball-ball",
134
+ "basketball-ball",
135
+ "beer",
136
+ "bible",
137
+ "biking",
138
+ "birthday-cake",
139
+ "blind",
140
+ "book-dead",
141
+ "book-reader",
142
+ "border-style",
143
+ "boxes",
144
+ "broadcast-tower",
145
+ "burn",
146
+ "bus-alt",
147
+ "car-alt",
148
+ "car-crash",
149
+ "chalkboard-teacher",
150
+ "chevron-circle-down",
151
+ "chevron-circle-left",
152
+ "chevron-circle-right",
153
+ "chevron-circle-up",
154
+ "clinic-medical",
155
+ "cloud-download-alt",
156
+ "cloud-upload-alt",
157
+ "cocktail",
158
+ "coffee",
159
+ "cog",
160
+ "cogs",
161
+ "columns",
162
+ "compress-alt",
163
+ "compress-arrows-alt",
164
+ "concierge-bell",
165
+ "crop-alt",
166
+ "cut",
167
+ "deaf",
168
+ "diagnoses",
169
+ "digital-tachograph",
170
+ "directions",
171
+ "dolly-flatbed",
172
+ "donate",
173
+ "drafting-compass",
174
+ "ellipsis-h",
175
+ "ellipsis-v",
176
+ "envelope-square",
177
+ "exchange-alt",
178
+ "exclamation-circle",
179
+ "exclamation-triangle",
180
+ "expand-alt",
181
+ "expand-arrows-alt",
182
+ "external-link-alt",
183
+ "external-link-square-alt",
184
+ "fast-backward",
185
+ "fast-forward",
186
+ "feather-alt",
187
+ "female",
188
+ "fighter-jet",
189
+ "file-download",
190
+ "file-medical-alt",
191
+ "file-upload",
192
+ "fire-alt",
193
+ "first-aid",
194
+ "fist-raised",
195
+ "football-ball",
196
+ "funnel-dollar",
197
+ "glass-cheers",
198
+ "glass-martini-alt",
199
+ "glass-martini",
200
+ "glass-whiskey",
201
+ "globe-africa",
202
+ "globe-americas",
203
+ "globe-asia",
204
+ "globe-europe",
205
+ "golf-ball",
206
+ "grip-horizontal",
207
+ "h-square",
208
+ "hamburger",
209
+ "hand-holding-usd",
210
+ "hand-holding-water",
211
+ "hands-helping",
212
+ "hands-wash",
213
+ "handshake-alt-slash",
214
+ "hard-hat",
215
+ "headphones-alt",
216
+ "heart-broken",
217
+ "heartbeat",
218
+ "hiking",
219
+ "history",
220
+ "home",
221
+ "hospital-alt",
222
+ "hospital-symbol",
223
+ "hot-tub",
224
+ "house-damage",
225
+ "hryvnia",
226
+ "id-card-alt",
227
+ "info-circle",
228
+ "journal-whills",
229
+ "laptop-house",
230
+ "level-down-alt",
231
+ "level-up-alt",
232
+ "long-arrow-alt-down",
233
+ "long-arrow-alt-left",
234
+ "long-arrow-alt-right",
235
+ "long-arrow-alt-up",
236
+ "low-vision",
237
+ "luggage-cart",
238
+ "magic",
239
+ "mail-bulk",
240
+ "male",
241
+ "map-marked-alt",
242
+ "map-marked",
243
+ "map-marker-alt",
244
+ "map-marker",
245
+ "map-signs",
246
+ "mars-stroke-h",
247
+ "mars-stroke-v",
248
+ "medkit",
249
+ "microphone-alt-slash",
250
+ "microphone-alt",
251
+ "minus-circle",
252
+ "mobile-alt",
253
+ "money-bill-wave-alt",
254
+ "money-check-alt",
255
+ "mouse-pointer",
256
+ "mouse",
257
+ "paint-brush",
258
+ "parking",
259
+ "pastafarianism",
260
+ "pen-alt",
261
+ "pen-square",
262
+ "pencil-alt",
263
+ "pencil-ruler",
264
+ "people-carry",
265
+ "percentage",
266
+ "phone-alt",
267
+ "phone-square-alt",
268
+ "phone-square",
269
+ "photo-video",
270
+ "plus-circle",
271
+ "poll-h",
272
+ "poll",
273
+ "portrait",
274
+ "pound-sign",
275
+ "pray",
276
+ "praying-hands",
277
+ "prescription-bottle-alt",
278
+ "procedures",
279
+ "project-diagram",
280
+ "quidditch",
281
+ "quran",
282
+ "radiation-alt",
283
+ "random",
284
+ "redo-alt",
285
+ "redo",
286
+ "remove-format",
287
+ "rss-square",
288
+ "running",
289
+ "search-dollar",
290
+ "search-location",
291
+ "search-minus",
292
+ "search-plus",
293
+ "search",
294
+ "share-alt-square",
295
+ "share-alt",
296
+ "shield-alt",
297
+ "shipping-fast",
298
+ "shopping-bag",
299
+ "shopping-basket",
300
+ "shopping-cart",
301
+ "shuttle-van",
302
+ "sign-in-alt",
303
+ "sign-language",
304
+ "sign-out-alt",
305
+ "sign",
306
+ "skating",
307
+ "skiing-nordic",
308
+ "skiing",
309
+ "sliders-h",
310
+ "smoking-ban",
311
+ "sms",
312
+ "snowboarding",
313
+ "sort-alpha-down-alt",
314
+ "sort-alpha-down",
315
+ "sort-alpha-up-alt",
316
+ "sort-alpha-up",
317
+ "sort-amount-down-alt",
318
+ "sort-amount-down",
319
+ "sort-amount-up-alt",
320
+ "sort-amount-up",
321
+ "sort-numeric-down-alt",
322
+ "sort-numeric-down",
323
+ "sort-numeric-up-alt",
324
+ "sort-numeric-up",
325
+ "space-shuttle",
326
+ "square-root-alt",
327
+ "star-half-alt",
328
+ "step-backward",
329
+ "step-forward",
330
+ "store-alt-slash",
331
+ "store-alt",
332
+ "stream",
333
+ "subway",
334
+ "swimmer",
335
+ "swimming-pool",
336
+ "sync-alt",
337
+ "sync",
338
+ "table-tennis",
339
+ "tablet-alt",
340
+ "tachometer-alt",
341
+ "tasks",
342
+ "tenge",
343
+ "th-large",
344
+ "th-list",
345
+ "th",
346
+ "theater-masks",
347
+ "thermometer-empty",
348
+ "thermometer-full",
349
+ "thermometer-half",
350
+ "thermometer-quarter",
351
+ "thermometer-three-quarters",
352
+ "ticket-alt",
353
+ "times",
354
+ "tint-slash",
355
+ "tint",
356
+ "tools",
357
+ "torah",
358
+ "tram",
359
+ "transgender-alt",
360
+ "trash-restore-alt",
361
+ "trash-restore",
362
+ "truck-loading",
363
+ "tshirt",
364
+ "undo-alt",
365
+ "undo",
366
+ "university",
367
+ "unlink",
368
+ "unlock-alt",
369
+ "user-alt-slash",
370
+ "user-alt",
371
+ "user-cog",
372
+ "user-edit",
373
+ "user-friends",
374
+ "user-md",
375
+ "user-times",
376
+ "users-cog",
377
+ "utensil-spoon",
378
+ "volleyball-ball",
379
+ "volume-down",
380
+ "volume-mute",
381
+ "volume-up",
382
+ "vote-yea",
383
+ "walking",
384
+ "weight",
385
+ "wine-glass-alt"
386
+ ]
387
+
388
+ module.exports = v5names
@@ -0,0 +1,9 @@
1
+ const wrapScrollViewInView = require('./rule')
2
+
3
+ const plugin = {
4
+ rules: {
5
+ 'wrap-horizontal-scrollview-inside-view': wrapScrollViewInView,
6
+ },
7
+ };
8
+
9
+ module.exports = plugin
@@ -0,0 +1,64 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: 'problem',
4
+ docs: {
5
+ description: '禁止带有 horizontal: true 属性的 ScrollView 单独使用',
6
+ recommended: false,
7
+ },
8
+ schema: [],
9
+ messages: {
10
+ noSiblings: '禁止带有 props.horizontal: true 的 ScrollView 单独使用,需要在 ScrollView 外层使用一个单独的 View 组件进行包裹',
11
+ },
12
+ },
13
+ create(context) {
14
+ return {
15
+ JSXElement(node) {
16
+ const isScrollView = node.openingElement.name.name === 'ScrollView';
17
+
18
+ if (!isScrollView) {
19
+ return;
20
+ }
21
+
22
+ const hasHorizontalProp = node.openingElement.attributes.some(attr => {
23
+ if (attr.type === 'JSXAttribute' && attr.name.name === 'horizontal') {
24
+ if (!attr.value) {
25
+ return true;
26
+ }
27
+ if (
28
+ attr.value.type === 'JSXExpressionContainer' &&
29
+ attr.value.expression.value === true
30
+ ) {
31
+ return true; // horizontal={true}
32
+ }
33
+ if (attr.value.type === 'Literal' && attr.value.value === true) {
34
+ return true; // horizontal={true} 的另一种形式
35
+ }
36
+ }
37
+ return false;
38
+ });
39
+
40
+ if (!hasHorizontalProp) {
41
+ return;
42
+ }
43
+
44
+ const parent = node.parent;
45
+
46
+ if (
47
+ parent.type === 'JSXFragment' ||
48
+ parent.type === 'JSXElement'
49
+ ) {
50
+ const siblings = parent.children.filter(
51
+ child => child.type === 'JSXElement' && child !== node
52
+ );
53
+
54
+ if (siblings.length > 0) {
55
+ context.report({
56
+ node,
57
+ messageId: 'noSiblings',
58
+ });
59
+ }
60
+ }
61
+ },
62
+ };
63
+ },
64
+ }
@@ -0,0 +1,9 @@
1
+ const banMixUse = require('./rule')
2
+
3
+ const plugin = {
4
+ rules: {
5
+ 'ban-mix-use': banMixUse,
6
+ },
7
+ };
8
+
9
+ module.exports = plugin
@@ -0,0 +1,88 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: 'problem',
4
+ docs: {
5
+ description:
6
+ 'Disallow passing useAnimatedScrollHandler return value to ScrollView',
7
+ recommended: 'error',
8
+ },
9
+ schema: [],
10
+ messages: {
11
+ noUseAnimatedScrollHandlerOnScroll:
12
+ 'Do not pass useAnimatedScrollHandler return value to ScrollView, pass to Animated.ScrollView instead.',
13
+ },
14
+ },
15
+
16
+ create(context) {
17
+ // 记录 useAnimatedScrollHandler 的本地名字
18
+ let useAnimatedScrollHandlerImportName = null;
19
+ // 记录 ScrollView 的本地名字
20
+ let scrollViewImportName = null;
21
+ // 记录调用 useAnimatedScrollHandler 返回值的变量名
22
+ const animatedScrollHandlerVars = new Set();
23
+
24
+ return {
25
+ ImportDeclaration(node) {
26
+ if (node.source.value === 'react-native-reanimated') {
27
+ for (const specifier of node.specifiers) {
28
+ if (
29
+ specifier.type === 'ImportSpecifier' &&
30
+ specifier.imported.name === 'useAnimatedScrollHandler'
31
+ ) {
32
+ useAnimatedScrollHandlerImportName = specifier.local.name;
33
+ }
34
+ }
35
+ }
36
+
37
+ if (node.source.value === 'react-native') {
38
+ for (const specifier of node.specifiers) {
39
+ if (
40
+ specifier.type === 'ImportSpecifier' &&
41
+ specifier.imported.name === 'ScrollView'
42
+ ) {
43
+ scrollViewImportName = specifier.local.name;
44
+ }
45
+ }
46
+ }
47
+ },
48
+
49
+ VariableDeclarator(node) {
50
+ if (
51
+ node.init &&
52
+ node.init.type === 'CallExpression' &&
53
+ node.init.callee.type === 'Identifier' &&
54
+ node.init.callee.name === useAnimatedScrollHandlerImportName
55
+ ) {
56
+ if (node.id.type === 'Identifier') {
57
+ animatedScrollHandlerVars.add(node.id.name);
58
+ }
59
+ }
60
+ },
61
+
62
+ JSXOpeningElement(node) {
63
+ if (
64
+ node.name.type === 'JSXIdentifier' &&
65
+ node.name.name === scrollViewImportName
66
+ ) {
67
+ for (const attr of node.attributes) {
68
+ if (
69
+ attr.type === 'JSXAttribute' &&
70
+ attr.name.name === 'onScroll' &&
71
+ attr.value &&
72
+ attr.value.type === 'JSXExpressionContainer' &&
73
+ attr.value.expression.type === 'Identifier'
74
+ ) {
75
+ const varName = attr.value.expression.name;
76
+ if (animatedScrollHandlerVars.has(varName)) {
77
+ context.report({
78
+ node: attr,
79
+ messageId: 'noUseAnimatedScrollHandlerOnScroll',
80
+ });
81
+ }
82
+ }
83
+ }
84
+ }
85
+ },
86
+ };
87
+ },
88
+ };
@@ -17,6 +17,9 @@
17
17
  "pnpm": {
18
18
  "overrides": {
19
19
  "esbuild": "0.27.2"
20
+ },
21
+ "patchedDependencies": {
22
+ "expo@54.0.32": "patches/expo@54.0.32.patch"
20
23
  }
21
24
  }
22
25
  }
@@ -0,0 +1,45 @@
1
+ diff --git a/src/async-require/hmr.ts b/src/async-require/hmr.ts
2
+ index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..3d78cb02dd7e96ac9727a2935d8178f2c7e95982 100644
3
+ --- a/src/async-require/hmr.ts
4
+ +++ b/src/async-require/hmr.ts
5
+ @@ -216,6 +216,40 @@ const HMRClient: HMRClientNativeInterface = {
6
+
7
+ client.on('update-done', () => {
8
+ hideLoading();
9
+ + if (process.env.EXPO_PUBLIC_COZE_PROJECT_ID && typeof window !== 'undefined' && window.location) {
10
+ + if((window as any).__updateTimeoutId) {
11
+ + clearTimeout((window as any).__updateTimeoutId);
12
+ + }
13
+ + const updateDoneTime = Date.now();
14
+ + (window as any).__updateDoneTime = updateDoneTime;
15
+ + (window as any).__updateTimeoutId = setTimeout(() => {
16
+ + const lastUpdateTime = (window as any).__updateDoneTime;
17
+ + if (lastUpdateTime !== updateDoneTime) return;
18
+ + const checkServerAndReload = (retriesLeft: number) => {
19
+ + if ((window as any).__updateDoneTime !== updateDoneTime) return;
20
+ + fetch(`/favicon.ico?_t=${Date.now()}`)
21
+ + .then((response) => {
22
+ + if (response.status === 200) {
23
+ + console.warn('[HMR] Server is ready (200), reloading now.');
24
+ + window.location.reload();
25
+ + } else {
26
+ + throw new Error(`Server status: ${response.status}`);
27
+ + }
28
+ + }).catch((error) => {
29
+ + console.warn(`[HMR] Check failed (${error.message}). Retries left: ${retriesLeft}`);
30
+ + if (retriesLeft > 0) {
31
+ + setTimeout(() => {
32
+ + checkServerAndReload(retriesLeft - 1);
33
+ + }, 5000);
34
+ + } else {
35
+ + console.error('[HMR] Server unreachable after 6 attempts. Abort reload.');
36
+ + }
37
+ + });
38
+ + };
39
+ + checkServerAndReload(6);
40
+ + }, 35_000);
41
+ + }
42
+ + console.log('[HMR] Update done.');
43
+ });
44
+
45
+ client.on('error', (data: { type: string; message: string }) => {