-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
223 additions
and
51 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
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,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 | ||
} |
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,7 @@ | ||
import { runSteps } from '../lib' | ||
|
||
export const cleanJest = (): number => { | ||
const pkgName = process.env.npm_package_name | ||
|
||
return runSteps(`Cleaning Jest [${pkgName}]`, [['jest', ['--clearCache']]]) | ||
} |
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 |
---|---|---|
@@ -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']]) | ||
} |
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
15 changes: 15 additions & 0 deletions
15
packages/ts-scripts-yarn3/src/actions/package/clean-outputs.ts
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,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
13
packages/ts-scripts-yarn3/src/actions/package/clean-typescript.ts
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,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 | ||
} |
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 |
---|---|---|
@@ -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() | ||
} |
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 |
---|---|---|
@@ -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' |
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,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) | ||
} |
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,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 | ||
} |
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,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import { packageCleanOutputs } from '../../actions' | ||
|
||
packageCleanOutputs() |
5 changes: 5 additions & 0 deletions
5
packages/ts-scripts-yarn3/src/bin/package/clean-typescript.ts
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,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import { packageCleanTypescript } from '../../actions' | ||
|
||
packageCleanTypescript() |
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,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 | ||
}) |
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,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import { runXyWithWarning } from "../lib" | ||
|
||
runXyWithWarning('recompile') |
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,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) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.