@astryxdesign/cli 0.7.5-canary.d9b43cf → 0.7.5-canary.dcdb356

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.
@@ -0,0 +1,47 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Contract test for the Tokenizer showcase block.
5
+ * @input The shipped TokenizerShowcase block source.
6
+ * @output Guards the block's search source: typing in the showcase must list
7
+ * matching tags rather than an empty menu.
8
+ * @position CLI template regression coverage; runs in the node test project.
9
+ * The block is the hero example of the Tokenizer docs page. Like the other
10
+ * template contract tests here it reads the block's source instead of
11
+ * importing it, so it needs no built `@astryxdesign/core`.
12
+ */
13
+
14
+ import fs from 'node:fs';
15
+ import path from 'node:path';
16
+ import {fileURLToPath} from 'node:url';
17
+ import {describe, expect, it} from 'vitest';
18
+
19
+ const sourcePath = path.resolve(
20
+ path.dirname(fileURLToPath(import.meta.url)),
21
+ '../../assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx',
22
+ );
23
+ const source = fs.readFileSync(sourcePath, 'utf8');
24
+
25
+ // Evaluate the block's tag list and search source on their own, with the
26
+ // type annotations removed, so the test exercises the shipped logic.
27
+ function loadSearchSource() {
28
+ const tags = source.match(/const tags[^=]*=\s*(\[[\s\S]*?\n\]);/)?.[1];
29
+ const searchSource = source.match(
30
+ /const source[^=]*=\s*(\{[\s\S]*?\n\});/,
31
+ )?.[1];
32
+ if (tags == null || searchSource == null) {
33
+ throw new Error('TokenizerShowcase no longer declares `tags` and `source`');
34
+ }
35
+ const untyped = searchSource.replace(/\((\w+):\s*string\)/g, '($1)');
36
+ return new Function(`const tags = ${tags}; return ${untyped};`)();
37
+ }
38
+
39
+ describe('Tokenizer showcase block', () => {
40
+ it('lists the tags that match a typed query, ignoring case', async () => {
41
+ const {search, bootstrap} = loadSearchSource();
42
+ const labels = async query => (await search(query)).map(tag => tag.label);
43
+ expect(await labels('mar')).toEqual(['Marketing']);
44
+ expect(await labels('A')).toEqual(['Marketing', 'Research', 'Sales']);
45
+ expect((await bootstrap()).length).toBeGreaterThan(0);
46
+ });
47
+ });
@@ -6,16 +6,23 @@ import {useState} from 'react';
6
6
  import {Tokenizer} from '@astryxdesign/core/Tokenizer';
7
7
  import type {SearchableItem, SearchSource} from '@astryxdesign/core/Typeahead';
8
8
 
9
+ const tags: SearchableItem[] = [
10
+ {id: '1', label: 'Design'},
11
+ {id: '2', label: 'Engineering'},
12
+ {id: '3', label: 'Marketing'},
13
+ {id: '4', label: 'Product'},
14
+ {id: '5', label: 'Research'},
15
+ {id: '6', label: 'Sales'},
16
+ ];
17
+
9
18
  const source: SearchSource = {
10
- search: () => [],
11
- bootstrap: () => [],
19
+ search: (query: string) =>
20
+ tags.filter(tag => tag.label.toLowerCase().includes(query.toLowerCase())),
21
+ bootstrap: () => tags,
12
22
  };
13
23
 
14
24
  export default function TokenizerShowcase() {
15
- const [value, setValue] = useState<SearchableItem[]>([
16
- {id: '1', label: 'Design'},
17
- {id: '2', label: 'Engineering'},
18
- ]);
25
+ const [value, setValue] = useState<SearchableItem[]>([tags[0], tags[1]]);
19
26
  return (
20
27
  <div style={{display: 'grid', gridTemplateColumns: 'minmax(0, 400px)'}}>
21
28
  <Tokenizer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.5-canary.d9b43cf",
3
+ "version": "0.7.5-canary.dcdb356",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -111,10 +111,10 @@
111
111
  "zod": "^4.4.3"
112
112
  },
113
113
  "peerDependencies": {
114
- "@astryxdesign/charts": "0.7.5-canary.d9b43cf",
115
- "@astryxdesign/core": "0.7.5-canary.d9b43cf",
116
- "@astryxdesign/lab": "0.7.5-canary.d9b43cf",
117
- "@astryxdesign/theme-neutral": "0.7.5-canary.d9b43cf"
114
+ "@astryxdesign/charts": "0.7.5-canary.dcdb356",
115
+ "@astryxdesign/core": "0.7.5-canary.dcdb356",
116
+ "@astryxdesign/lab": "0.7.5-canary.dcdb356",
117
+ "@astryxdesign/theme-neutral": "0.7.5-canary.dcdb356"
118
118
  },
119
119
  "peerDependenciesMeta": {
120
120
  "@astryxdesign/charts": {
@@ -131,10 +131,10 @@
131
131
  }
132
132
  },
133
133
  "devDependencies": {
134
- "@astryxdesign/charts": "0.7.5-canary.d9b43cf",
135
- "@astryxdesign/core": "0.7.5-canary.d9b43cf",
136
- "@astryxdesign/lab": "0.7.5-canary.d9b43cf",
137
- "@astryxdesign/theme-neutral": "0.7.5-canary.d9b43cf",
134
+ "@astryxdesign/charts": "0.7.5-canary.dcdb356",
135
+ "@astryxdesign/core": "0.7.5-canary.dcdb356",
136
+ "@astryxdesign/lab": "0.7.5-canary.dcdb356",
137
+ "@astryxdesign/theme-neutral": "0.7.5-canary.dcdb356",
138
138
  "@heroicons/react": "^2.2.0",
139
139
  "@stylexjs/stylex": "^0.19.0",
140
140
  "@types/babel__core": "^7.20.5",