forked from FormidableLabs/victory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-scripts.js
92 lines (84 loc) · 3.77 KB
/
package-scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* We generally use `nps` for scripts that we:
* 1. define at the root of the monorepo
* 2. that are meant to execute _within_ a workspace
*
* ... or ...
*
* - That could use a little JS magic that we don't want to write a full
* node script for 😂
*
* For more cases, if you have an actual root task, define it in root
* `package.json:scripts`.
*/
const path = require("path");
const PKG_SRC = path.resolve("src");
// For publishing, use the core package's version.
const coreVersion = require("./packages/victory-core/package.json").version;
if (!coreVersion) {
throw new Error("Unable to read core version");
}
const coreTag = `v${coreVersion}`;
module.exports = {
scripts: {
// Root tasks.
// Try to find an existing tag (from previous attempts, etc.), and if not, create one.
"git:tag": `git show-ref ${coreTag} || git tag -a ${coreTag} -m \"Version ${coreVersion}\"`,
// Build.
// - Libraries
"build:lib:esm":
"cross-env BABEL_ENV=es babel src --out-dir es --config-file ../../.babelrc.build.js --extensions .tsx,.ts,.jsx,.js",
"build:lib:cjs":
"cross-env BABEL_ENV=commonjs babel src --out-dir lib --config-file ../../.babelrc.build.js --extensions .tsx,.ts,.jsx,.js",
// - UMD distributions
// TODO(2375): Add / verify caching
// https://github.com/FormidableLabs/victory/issues/2375
"build:dist:dev":
"webpack --bail --config ../../config/webpack/webpack.config.dev.js",
"build:dist:min":
"webpack --bail --config ../../config/webpack/webpack.config.js",
// Quality.
// - Format
// TODO(2375): Can we cache / incremental?
// https://github.com/FormidableLabs/victory/issues/2375
"format:pkg":
'prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --list-different "./**/*.{js,jsx,json,ts,tsx}"',
"format:pkg:fix":
'prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --write "./**/*.{js,jsx,json,ts,tsx}"',
"format:root":
'prettier --list-different "./*.js*" "./{scripts,config,demo,docs,stories,test}/*.{js,jsx,json,ts,tsx}"',
"format:root:fix":
'prettier --write "./*.js*" "./{scripts,config,demo,docs,stories,test}/*.{js,jsx,json,ts,tsx}"',
// - Lint
"lint:base": "eslint --cache --color",
"lint:pkg": 'nps "lint:base src"',
"lint:pkg:fix": 'nps "lint:base --fix src"',
// Tests
// - Jest
// TODO(2375): Can we cache / incremental?
// https://github.com/FormidableLabs/victory/issues/2375
"jest:native": `cross-env BABEL_ENV=commonjs jest --config=../../test/jest-native-config.js --testPathPattern=${PKG_SRC}`,
"jest:pkg": `cross-env BABEL_ENV=commonjs jest --config=../../test/jest-config.js --passWithNoTests --testPathPattern=${PKG_SRC}`,
// TODO(2348): Hook coverage up to CI
// https://github.com/FormidableLabs/victory/issues/2348
// TODO(2348): Add this to `check:ci`
"jest:cov": "echo TODO",
// - TypeScript
// TODO(2375): Can we cache / incremental?
// https://github.com/FormidableLabs/victory/issues/2375
// Check for errors (includes test files):
"types:pkg:check": "tsc --pretty --noEmit",
// To create types, we must do the following:
// 1. Copy all *.d.ts files to the es folder
// 2. Compile all *.ts files to the es folder
// 3. Copy all output from the es folder to the lib folder
"types:pkg:create":
"nps types:pkg:copy types:pkg:compile types:pkg:cjs-copy",
"types:pkg:copy": 'cpx "src/**/*.d.ts" es',
"types:pkg:compile":
"tsc --pretty -p ./tsconfig.build.json --emitDeclarationOnly --rootDir src --outDir es || nps types:warning",
"types:warning":
'echo "Warning: found TypeScript errors during build. Continuing anyway!"',
"types:pkg:cjs-copy": 'cpx "es/**/*{.d.ts,.d.ts.map}" lib',
},
};