Skip to content

Commit

Permalink
add 🚀 arc config watch query option
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstyles committed May 22, 2024
1 parent 99e9b77 commit 0fc7709
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/arc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@urban-ui/arc",
"version": "0.2.0",
"version": "0.3.0",
"description": "Kit builder for urban ui packages",
"module": "./rk.ts",
"types": "./rk.d.ts",
Expand Down
16 changes: 16 additions & 0 deletions scripts/arc/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const buildCommand: CommandModule = {

return {
include: files,
watchQuery: argv.watchQuery,
outDir: argv.outDir,
rootDir: argv.rootDir,
events: argv.events,
Expand Down Expand Up @@ -95,6 +96,21 @@ export const buildCommand: CommandModule = {
),
)

log.arc.log(
chalk.green('✔︎ Pipeline successful '),
chalk.dim(
'|',
[
`dts ${prettyFullRuntime(
getFullPipelineRuntime(dtsStats.pipeline),
)}`,
`compile ${prettyFullRuntime(
getFullPipelineRuntime(stats.pipeline),
)}`,
].join(' | '),
),
)

// Event
log.arc.debug('[event] onComplete')
await opts.events.complete() // @TODO pass in run analytics
Expand Down
4 changes: 3 additions & 1 deletion scripts/arc/src/commands/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const watchCommand: CommandModule = {

return {
include: files,
watchQuery: argv.watchQuery,
outDir: argv.outDir,
rootDir: argv.rootDir,
events: argv.events,
Expand Down Expand Up @@ -76,7 +77,8 @@ export const watchCommand: CommandModule = {
]
const sub = {
// expression: ['anyof', ['name', opts.include, 'wholename']],
expression: query,
// expression: query,
expression: opts.watchQuery,
fields: [
'name',
'size',
Expand Down
25 changes: 23 additions & 2 deletions scripts/arc/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import { cosmiconfig } from 'cosmiconfig'
import type { Recursive } from 'type-fest/source/multidimensional-readonly-array'

interface Wop<T> extends Array<T | Wop<T>> {}
type WatchmanQuery = Wop<string>

export type Config<T = Record<string | number | symbol, unknown>> = T & {
/**
* Array of globs to include for transformation
* @default ['src']
* @default ['src', '!**\/*.test.ts*']
*/
include?: Array<string>
/**
* Query to pass to watchman.
* Ideally we would pass the glob to watchman but the watchman query is a lot more powerful than a glob.
* @default [
* 'allof',
* ['match', `${opts.rootDir}\/**\/*`, 'wholename'],
* ['suffix', ['ts', 'tsx', 'js', 'jsx']],
* ['not', ['suffix', ['test.ts', 'test.tsx']]],
* ]
*/
watchQuery?: WatchmanQuery
/**
* Output directory
* @default dist
Expand Down Expand Up @@ -38,7 +53,13 @@ function noop() {
}

const defaultConfig: Required<Config> = {
include: ['src'],
include: ['src', '!**/*.test.ts*'],
watchQuery: [
'allof',
['match', 'src/**/*', 'wholename'],
['suffix', ['ts', 'tsx', 'js', 'jsx']],
['not', ['suffix', ['test.ts', 'test.tsx']]],
],
outDir: 'dist',
rootDir: 'src',
events: {
Expand Down

0 comments on commit 0fc7709

Please sign in to comment.