Skip to content

Commit

Permalink
Merge branch 'next' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Mar 2, 2023
2 parents 733e7fc + d5cef95 commit 459045b
Show file tree
Hide file tree
Showing 40 changed files with 297 additions and 67 deletions.
12 changes: 12 additions & 0 deletions .yarn/versions/5bd80959.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
releases:
"@xylabs/config": minor
"@xylabs/eslint-config": minor
"@xylabs/eslint-config-react": minor
"@xylabs/ts-scripts": minor
"@xylabs/ts-scripts-react-yarn3": minor
"@xylabs/ts-scripts-yarn3": minor
"@xylabs/tsconfig": minor
"@xylabs/tsconfig-dom": minor
"@xylabs/tsconfig-dom-jest": minor
"@xylabs/tsconfig-jest": minor
"@xylabs/tsconfig-react": minor
12 changes: 12 additions & 0 deletions .yarn/versions/95cac132.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
releases:
"@xylabs/config": minor
"@xylabs/eslint-config": minor
"@xylabs/eslint-config-react": minor
"@xylabs/ts-scripts": minor
"@xylabs/ts-scripts-react-yarn3": minor
"@xylabs/ts-scripts-yarn3": minor
"@xylabs/tsconfig": minor
"@xylabs/tsconfig-dom": minor
"@xylabs/tsconfig-dom-jest": minor
"@xylabs/tsconfig-jest": minor
"@xylabs/tsconfig-react": minor
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@typescript-eslint/parser": "^5.53.0",
"@xylabs/eslint-config": "workspace:^",
"@xylabs/ts-scripts-yarn3": "workspace:^",
"@xylabs/tsconfig": "^2.15.0",
"@xylabs/tsconfig": "^2.16.0-rc.2",
"cpy-cli": "^4.2.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
Expand Down Expand Up @@ -66,7 +66,7 @@
"node": ">=14.16"
},
"sideEffects": false,
"version": "2.15.0",
"version": "2.16.0-rc.2",
"packageManager": "[email protected]",
"scripts": {
"build": "echo Building... && yarn compile",
Expand All @@ -79,5 +79,6 @@
"deploy-patch": "yarn workspaces foreach --all version patch --deferred && yarn deploy-common",
"deploy-common": "yarn build && yarn version apply --all && yarn workspaces foreach -ptv npm publish",
"deploy-next": "yarn workspaces foreach --all version minor --deferred && yarn build && yarn version apply --all --prerelease && yarn workspaces foreach -ptv npm publish --tag next"
}
},
"stableVersion": "2.15.0"
}
3 changes: 2 additions & 1 deletion packages/eslint-config-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"url": "https://github.com/xylabs/config.git"
},
"sideEffects": false,
"version": "2.15.0"
"version": "2.16.0-rc.2",
"stableVersion": "2.15.0"
}
3 changes: 2 additions & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@
"url": "https://github.com/xylabs/config.git"
},
"sideEffects": false,
"version": "2.15.0"
"version": "2.16.0-rc.2",
"stableVersion": "2.15.0"
}
3 changes: 2 additions & 1 deletion packages/ts-scripts-react-yarn3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@
"node": ">=14.16"
},
"sideEffects": false,
"version": "2.15.0"
"version": "2.16.0-rc.2",
"stableVersion": "2.15.0"
}
5 changes: 4 additions & 1 deletion packages/ts-scripts-yarn3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
"package-copy-assets-esm": "dist/cjs/bin/package/copy-assets-esm.js",
"package-deps": "dist/cjs/bin/package/deps.js",
"package-gen-docs": "dist/cjs/bin/package/gen-docs.js",
"package-recompile": "dist/cjs/bin/package/recompile.js",
"package-tsconfig-gen": "dist/cjs/bin/package/tsconfig-gen.js",
"package-tsconfig-gen-cjs": "dist/cjs/bin/package/tsconfig-gen-cjs.js",
"package-tsconfig-gen-esm": "dist/cjs/bin/package/tsconfig-gen-esm.js",
"rebuild": "dist/cjs/bin/rebuild.js",
"recompile": "dist/cjs/bin/recompile.js",
"reinstall": "dist/cjs/bin/reinstall.js",
"relint": "dist/cjs/bin/relint.js",
"sonar": "dist/cjs/bin/sonar.js",
Expand Down Expand Up @@ -144,5 +146,6 @@
"compile": "tsc --build tsconfig.build.cjs.json && tsc --build tsconfig.build.esm.json"
},
"sideEffects": false,
"version": "2.15.0"
"version": "2.16.0-rc.2",
"stableVersion": "2.15.0"
}
4 changes: 2 additions & 2 deletions packages/ts-scripts-yarn3/src/actions/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const build = async ({ incremental, jobs, target, verbose, pkg }: BuildPa
}

const result = await runStepsAsync(`Build${incremental ? '-Incremental' : ''} [${pkg ?? 'All'}]`, [
['yarn', ['xy', 'compile', ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
['yarn', ['xy', 'lint', ...pkgOptions, ...verboseOptions, ...incrementalOptions]],
['yarn', ['xy', 'recompile', ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
['yarn', ['xy', 'relint', ...pkgOptions, ...verboseOptions, ...incrementalOptions]],
['yarn', ['xy', 'deps', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
])
console.log(`${chalk.gray('Built in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)
Expand Down
12 changes: 12 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/clean-eslint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import chalk from 'chalk'
import { rimrafSync } from 'rimraf'

export const cleanESLint = () => {
const pkg = process.env.INIT_CWD
const pkgName = process.env.npm_package_name
console.log(chalk.green(`Cleaning ESLint [${pkgName}]`))

rimrafSync(`${pkg}/.eslintcache`)

return 0
}
7 changes: 7 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/clean-jest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { runSteps } from '../lib'

export const cleanJest = (): number => {
const pkgName = process.env.npm_package_name

return runSteps(`Cleaning Jest [${pkgName}]`, [['jest', ['--clearCache']]])
}
4 changes: 3 additions & 1 deletion packages/ts-scripts-yarn3/src/actions/clean.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { runSteps } from '../lib'
import { cleanESLint } from './clean-eslint'
import { cleanJest } from './clean-jest'

export interface CleanParams {
pkg?: string
}

export const clean = () => {
return runSteps('Clean', [['yarn', 'workspaces foreach -pA run package-clean']])
return cleanJest() + cleanESLint() + runSteps('Clean', [['yarn', 'workspaces foreach -pA run package-clean']])
}
2 changes: 2 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export * from './lint-clean'
export * from './lint-profile'
export * from './package'
export * from './rebuild'
export * from './recompile'
export * from './reinstall'
export * from './relint'
export * from './retest'
export * from './sonar'
export * from './statics'
export * from './test'
Expand Down
15 changes: 15 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/package/clean-outputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import chalk from 'chalk'
import { rmSync } from 'fs'

export const packageCleanOutputs = () => {
const pkg = process.env.INIT_CWD
const pkgName = process.env.npm_package_name
console.log(chalk.green(`Cleaning Outputs [${pkgName}]`))

const dist = `${pkg}/dist`
rmSync(dist, { force: true, recursive: true })

const build = `${pkg}/build`
rmSync(build, { force: true, recursive: true })
return 0
}
13 changes: 13 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/package/clean-typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import chalk from 'chalk'
import { rimrafSync } from 'rimraf'

export const packageCleanTypescript = () => {
const pkg = process.env.INIT_CWD
const pkgName = process.env.npm_package_name
console.log(chalk.green(`Cleaning Typescript [${pkgName}]`))

rimrafSync(`${pkg}/*.tsbuildinfo`)
rimrafSync(`${pkg}/.tsconfig.*`)

return 0
}
18 changes: 3 additions & 15 deletions packages/ts-scripts-yarn3/src/actions/package/clean.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import chalk from 'chalk'
import { rmSync } from 'fs'
import { rimrafSync } from 'rimraf'
import { packageCleanOutputs } from './clean-outputs'
import { packageCleanTypescript } from './clean-typescript'

export const packageClean = () => {
const pkg = process.env.INIT_CWD
const pkgName = process.env.npm_package_name
console.log(chalk.green(`Cleaning [${pkgName}]`))

const dist = `${pkg}/dist`
rmSync(dist, { force: true, recursive: true })

const build = `${pkg}/build`
rmSync(build, { force: true, recursive: true })

rimrafSync(`${pkg}/**/*.tsbuildinfo`)
rimrafSync(`${pkg}/**/.tsconfig.*`)
return packageCleanOutputs() + packageCleanTypescript()
}
5 changes: 5 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/package/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import chalk from 'chalk'
import depcheck, { special } from 'depcheck'
import { existsSync, readFileSync } from 'fs'

import { checkResult } from '../../lib'

export const packageDeps = async () => {
const pkg = process.env.INIT_CWD
const pkgName = process.env.npm_package_name
Expand Down Expand Up @@ -93,6 +95,9 @@ export const packageDeps = async () => {
})
console.log(chalk.yellow(message.join('\n')))
}

checkResult(`Deps [${pkgName}]`, errorCount, 'warn', false)

//returning 0 here since we never want deps to be fatal
return 0
}
3 changes: 3 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/package/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
export * from './clean'
export * from './clean-outputs'
export * from './clean-typescript'
export * from './compile'
export * from './compile-cjs'
export * from './compile-esm'
export * from './copy-assets'
export * from './deps'
export * from './gen-docs'
export * from './recompile'
export * from './tsconfig-gen-cjs'
export * from './tsconfig-gen-esm'
7 changes: 7 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/package/recompile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { packageClean } from './clean'
import { packageCompileCjs } from './compile-cjs'
import { packageCompileEsm } from './compile-esm'

export const packageRecompile = async () => {
return (await Promise.all([packageClean(), packageCompileEsm(), packageCompileCjs()])).reduce((prev, value) => prev + value, 0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFileSync, writeFileSync } from 'fs'

import { createBuildConfig } from '../../lib'

export const packageTsconfigGenEsm = () => {
export const packageTsconfigGenEsm = (quiet = false) => {
const pkg = process.env.INIT_CWD ?? './'
const pkgName = process.env.npm_package_name

Expand All @@ -19,7 +19,9 @@ export const packageTsconfigGenEsm = () => {
currentConfig = undefined
}
if (currentConfig !== config) {
console.log(chalk.gray(`Updating ESM tsconfig [${pkgName}]`))
if (!quiet) {
console.log(chalk.gray(`Updating ESM tsconfig [${pkgName}]`))
}
writeFileSync(`${pkg}/.tsconfig.build.esm.json`, config, { encoding: 'utf8' })
}
}
Expand Down
45 changes: 45 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/recompile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import chalk from 'chalk'

import { runStepsAsync } from '../lib'

export interface RecompileParams {
incremental?: boolean
jobs?: number
pkg?: string
target?: 'esm' | 'cjs'
verbose?: boolean
}

export interface RecompilePackageParams {
pkg: string
target?: 'esm' | 'cjs'
verbose?: boolean
}

export const recompile = async ({ verbose, target, pkg, incremental }: RecompileParams) => {
return pkg ? await recompilePackage({ pkg, target, verbose }) : await recompileAll({ incremental, target, verbose })
}

export const recompilePackage = ({ verbose, target, pkg }: RecompilePackageParams) => {
const verboseOptions = verbose ? ['-v'] : []
const targetOptions = target ? ['-t', target] : []

return runStepsAsync(`Recompile [${pkg}]`, [['yarn', ['workspace', pkg, 'run', 'package-recompile', ...verboseOptions, ...targetOptions]]])
}

export const recompileAll = async ({ jobs, verbose, target, incremental }: RecompileParams) => {
const start = Date.now()
const verboseOptions = verbose ? ['-v'] : []
const targetOptions = target ? ['-t', target] : []
const incrementalOptions = incremental ? ['--since', '-ptA'] : ['-ptA']
const jobsOptions = jobs ? ['-j', `${jobs}`] : []
if (jobs) {
console.log(chalk.blue(`Jobs set to [${jobs}]`))
}

const result = await runStepsAsync(`Recompile${incremental ? '-Incremental' : ''} [All]`, [
['yarn', ['workspaces', 'foreach', ...incrementalOptions, ...jobsOptions, 'run', 'package-recompile', ...verboseOptions, ...targetOptions]],
])
console.log(`${chalk.gray('Recompiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)
return result
}
8 changes: 8 additions & 0 deletions packages/ts-scripts-yarn3/src/actions/retest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { runSteps } from '../lib'

export const retest = () => {
return runSteps('Test', [
['yarn', ['jest', '--clearCache']],
['yarn', ['jest', '.']],
])
}
5 changes: 5 additions & 0 deletions packages/ts-scripts-yarn3/src/bin/package/clean-outputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import { packageCleanOutputs } from '../../actions'

packageCleanOutputs()
5 changes: 5 additions & 0 deletions packages/ts-scripts-yarn3/src/bin/package/clean-typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import { packageCleanTypescript } from '../../actions'

packageCleanTypescript()
9 changes: 9 additions & 0 deletions packages/ts-scripts-yarn3/src/bin/package/recompile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

import chalk from 'chalk'
import { packageRecompile } from '../../actions'

packageRecompile().then((value) => process.exitCode = value).catch((reason) => {
console.error(chalk.red(reason))
process.exitCode = 1
})
5 changes: 5 additions & 0 deletions packages/ts-scripts-yarn3/src/bin/recompile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import { runXyWithWarning } from "../lib"

runXyWithWarning('recompile')
12 changes: 12 additions & 0 deletions packages/ts-scripts-yarn3/src/lib/checkResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import chalk from 'chalk'

export const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {
if (result) {
const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'
const chalkFunc = level === 'error' ? chalk.red : chalk.yellow
console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))
if (exitOnFail) {
process.exit(result)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ export const detectDuplicateDependencies = (depsFromPackageJSON?: string[], Defa
} catch (e) {
console.error(`Error running yarn why: ${e}`)
exitCode = 1
return
return exitCode
}

if (output) {
exitCode = new DuplicateDetector(output, dependency).detect()
return
return exitCode
} else {
console.log(`${dependency} - N/A`)
if (depsFromPackageJSON) {
console.log(`🚨 Library ${dependency} was requested in package.json but not found`)
}
exitCode = 1
return
return exitCode
}
})
return exitCode
} else {
console.log('🚨 No dependencies where passed')
return exitCode
}
})
}
1 change: 1 addition & 0 deletions packages/ts-scripts-yarn3/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './checkResult'
export * from './createBuildConfig'
export * from './defaultBuildConfig'
export * from './dependencies'
Expand Down
Loading

0 comments on commit 459045b

Please sign in to comment.