-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: util recusion and prefixing (#437)
- Loading branch information
1 parent
deeb0df
commit 26e2ab1
Showing
40 changed files
with
703 additions
and
1,807 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** Root directory. */ | ||
export const rootUrl = new URL('../', import.meta.url) | ||
|
||
/** Packages directory. */ | ||
export const packagesUrl = new URL('packages/', rootUrl) | ||
|
||
/** Core package directory. */ | ||
export const corePackageUrl = new URL('core/', packagesUrl) | ||
|
||
/** React package directory. */ | ||
export const reactPackageUrl = new URL('react/', packagesUrl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import fs from './fs.mjs' | ||
import { corePackageUrl, reactPackageUrl, rootUrl } from './build-dirs.mjs' | ||
import { bold, dim, underline } from './color.mjs' | ||
|
||
async function buildShared(packageUrl) { | ||
const sharedUrl = new URL('shared/', rootUrl) | ||
const packageJsonUrl = new URL(`package.json`, packageUrl) | ||
const packageName = JSON.parse(await fs.readFile(packageJsonUrl, 'utf8')).name | ||
|
||
for (const dirent of await fs.readdir(sharedUrl, { withFileTypes: true })) { | ||
const sourceUrl = new URL(dirent.name + '/', sharedUrl) | ||
const sourceLog = sourceUrl.pathname.slice(rootUrl.pathname.length, -1) | ||
|
||
if (dirent.isDirectory()) { | ||
const targetUrl = new URL(dirent.name + '/', packageUrl) | ||
|
||
await fs.rmdir(targetUrl, { recursive: true }) | ||
|
||
await fs.copydir(sourceUrl, targetUrl) | ||
|
||
console.log([bold(sourceLog), dim('copied to'), bold(underline(packageName))].join(' ')) | ||
} | ||
} | ||
} | ||
|
||
export default buildShared | ||
|
||
const metaUrl = new URL(import.meta.url) | ||
const argvUrl = new URL(process.argv[1], 'file:') | ||
|
||
if (metaUrl.href === argvUrl.href) { | ||
console.log('') | ||
|
||
buildShared(corePackageUrl) | ||
buildShared(reactPackageUrl) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import nodemon from 'nodemon' | ||
|
||
nodemon( | ||
[ | ||
// prettier-ignore | ||
`--watch packages/core/src`, | ||
`--watch packages/core/tests`, | ||
`--watch packages/core/types`, | ||
`--watch packages/react/src`, | ||
`--watch packages/react/tests`, | ||
`--watch packages/react/types`, | ||
|
||
// exec | ||
`--exec "${['npm', 'run', 'build'].concat(process.argv.slice(2)).join(' ')}"`, | ||
].join(' '), | ||
) | ||
.on('start', () => { | ||
process.stdout.write('\u001b[3J\u001b[2J\u001b[1J') | ||
console.clear() | ||
}) | ||
.on('quit', () => process.exit()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import buildPackage from './build-package.mjs' | ||
import buildShared from './build-shared.mjs' | ||
import fs from './fs.mjs' | ||
import { corePackageUrl, reactPackageUrl } from './build-dirs.mjs' | ||
|
||
async function build() { | ||
console.log() | ||
|
||
await fs.rmdir(new URL('dist/', corePackageUrl), { recursive: true }) | ||
await fs.rmdir(new URL('dist/', reactPackageUrl), { recursive: true }) | ||
|
||
await buildPackage(corePackageUrl) | ||
|
||
console.log() | ||
|
||
await buildPackage(reactPackageUrl) | ||
|
||
console.log() | ||
|
||
await buildShared(corePackageUrl) | ||
|
||
await buildShared(reactPackageUrl) | ||
|
||
console.log() | ||
} | ||
|
||
const metaUrl = new URL(import.meta.url) | ||
const argvUrl = new URL(process.argv[1], 'file:') | ||
|
||
if (metaUrl.href === argvUrl.href) build() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import fs from 'fs/promises' | ||
import { copyFile, mkdir, readdir } from 'fs/promises' | ||
|
||
export * from 'fs/promises' | ||
|
||
/** Asynchronously copies dir to dest. By default, dest is overwritten if it already exists. */ | ||
export const copydir = async function copydir(src, dest) { | ||
await mkdir(dest, { recursive: true }) | ||
|
||
const dirents = await readdir(src, { withFileTypes: true }) | ||
|
||
for (const dirent of dirents) { | ||
const sourceURL = new URL(dirent.name + '/', src) | ||
const targetURL = new URL(dirent.name + '/', dest) | ||
if (dirent.isDirectory()) await copydir(sourceURL, targetURL) | ||
} | ||
|
||
for (const dirent of dirents) { | ||
const sourceURL = new URL(dirent.name, src) | ||
const targetURL = new URL(dirent.name, dest) | ||
if (!dirent.isDirectory()) await copyFile(sourceURL, targetURL) | ||
} | ||
} | ||
|
||
fs.copydir = copydir | ||
|
||
export default fs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import nodemon from 'nodemon' | ||
|
||
nodemon( | ||
[ | ||
// prettier-ignore | ||
`--watch packages/core/src`, | ||
`--watch packages/core/tests`, | ||
`--watch packages/react/src`, | ||
`--watch packages/react/tests`, | ||
`--exec "clear; ${['node', '.bin/test.mjs'].concat(process.argv.slice(2)).join(' ')}"`, | ||
].join(' '), | ||
) | ||
.on('start', () => { | ||
process.stdout.write('\u001b[3J\u001b[2J\u001b[1J') | ||
console.clear() | ||
}) | ||
.on('quit', () => process.exit()) |
Oops, something went wrong.