Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output consistency across platforms #181

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"preview": "vitepress preview",
"typecheck": "vue-tsc --noEmit",
"typecheck:registry": "vue-tsc --noEmit -p tsconfig.registry.json",
"build:registry": "typecheck:registry && tsx ./scripts/build-registry.ts"
"build:registry": "pnpm typecheck:registry && tsx ./scripts/build-registry.ts"
},
"dependencies": {
"@formkit/auto-animate": "^0.8.0",
Expand Down
11 changes: 9 additions & 2 deletions apps/www/scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ fs.writeFileSync(path.join(process.cwd(), '__registry__/index.ts'), index)
// ----------------------------------------------------------------------------
// Build registry/styles/[style]/[name].json.
// ----------------------------------------------------------------------------
const newLine = '\n'

for (const style of styles) {
const targetPath = path.join(REGISTRY_PATH, 'styles', style.name)

Expand All @@ -78,11 +80,14 @@ for (const style of styles) {
continue

const files = item.files?.map((file) => {
const content = fs.readFileSync(
let content = fs.readFileSync(
path.join(process.cwd(), 'src/lib/registry', style.name, file),
'utf8',
)

// Replace Windows-style newlines with Unix-style newlines
content = content.replace(/\r\n/g, newLine)

return {
name: basename(file),
content,
Expand All @@ -94,9 +99,11 @@ for (const style of styles) {
files,
}

const payloadStr = JSON.stringify(payload, null, 2).replace(/\r\n/g, newLine)

fs.writeFileSync(
path.join(targetPath, `${item.name}.json`),
JSON.stringify(payload, null, 2),
payloadStr,
'utf8',
)
}
Expand Down
1 change: 1 addition & 0 deletions apps/www/src/lib/registry/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ async function buildUIRegistry(componentPath: string, componentName: string) {

const file_path = join('ui', componentName, dirent.name)
files.push(file_path)
files.sort()

// only grab deps from the vue files
if (dirent.name === 'index.ts')
Expand Down
Loading