@apollion-dsi/scripts 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/coverage/clover.xml +21 -5
- package/coverage/coverage-final.json +2 -1
- package/coverage/lcov-report/config/env.ts.html +2 -2
- package/coverage/lcov-report/config/index.html +1 -1
- package/coverage/lcov-report/config/paths.ts.html +1 -1
- package/coverage/lcov-report/config/shared.ts.html +1 -1
- package/coverage/lcov-report/index.html +18 -18
- package/coverage/lcov-report/utils/checkRequiredFiles.ts.html +1 -1
- package/coverage/lcov-report/utils/formatWebpackMessages.ts.html +1 -1
- package/coverage/lcov-report/utils/getPublicUrlOrPath.ts.html +1 -1
- package/coverage/lcov-report/utils/index.html +23 -8
- package/coverage/lcov-report/utils/resolveBin.ts.html +193 -0
- package/coverage/lcov.info +34 -2
- package/eslint.config.js +4 -4
- package/lib/bin.js +8 -3
- package/lib/bin.js.map +1 -1
- package/lib/command/audit.d.ts +1 -0
- package/lib/command/audit.js +44 -0
- package/lib/command/audit.js.map +1 -0
- package/lib/command/check-types.d.ts +1 -0
- package/lib/command/check-types.js +18 -0
- package/lib/command/check-types.js.map +1 -0
- package/lib/command/create/helper.js +0 -1
- package/lib/command/create/helper.js.map +1 -1
- package/lib/command/create/index.js +7 -5
- package/lib/command/create/index.js.map +1 -1
- package/lib/command/lint.d.ts +1 -0
- package/lib/command/lint.js +31 -0
- package/lib/command/lint.js.map +1 -0
- package/lib/command/prettier.d.ts +1 -0
- package/lib/command/prettier.js +31 -0
- package/lib/command/prettier.js.map +1 -0
- package/lib/command/test.js +2 -5
- package/lib/command/test.js.map +1 -1
- package/lib/command/validate.d.ts +1 -0
- package/lib/command/validate.js +51 -0
- package/lib/command/validate.js.map +1 -0
- package/lib/config/webpack.config.js +6 -7
- package/lib/config/webpack.config.js.map +1 -1
- package/lib/utils/resolveBin.d.ts +13 -0
- package/lib/utils/resolveBin.js +35 -0
- package/lib/utils/resolveBin.js.map +1 -0
- package/llms.txt +51 -2
- package/package.json +10 -4
- package/src/__tests__/resolveBin.test.ts +68 -0
- package/src/bin.ts +11 -3
- package/src/command/audit.ts +46 -0
- package/src/command/check-types.ts +18 -0
- package/src/command/create/helper.ts +0 -1
- package/src/command/create/index.ts +7 -5
- package/src/command/lint.ts +31 -0
- package/src/command/prettier.ts +32 -0
- package/src/command/test.ts +2 -2
- package/src/command/validate.ts +66 -0
- package/src/config/webpack.config.js +6 -7
- package/src/utils/resolveBin.ts +36 -0
- package/template/src/App.tsx +5 -2
- package/template/src/index.tsx +8 -6
- package/template/tsconfig.json +3 -24
- package/tsconfig.base.json +19 -0
- package/template/audit-ci.json +0 -5
|
@@ -11,7 +11,7 @@ const ModuleNotFoundPlugin_1 = __importDefault(require("../utils/ModuleNotFoundP
|
|
|
11
11
|
const ModuleScopePlugin_1 = __importDefault(require("../utils/ModuleScopePlugin"));
|
|
12
12
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
13
13
|
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
14
|
-
const git_revision_webpack_plugin_1 =
|
|
14
|
+
const git_revision_webpack_plugin_1 = require("git-revision-webpack-plugin");
|
|
15
15
|
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
16
16
|
const resolve_1 = __importDefault(require("resolve"));
|
|
17
17
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
@@ -22,7 +22,7 @@ const env_1 = __importDefault(require("./env"));
|
|
|
22
22
|
const modules_1 = __importDefault(require("./modules"));
|
|
23
23
|
exports.default = (webpackEnv, paths, options = {}) => {
|
|
24
24
|
const appPackageJson = require(paths.appPackageJson);
|
|
25
|
-
const GitRevisionPlugin = new git_revision_webpack_plugin_1.
|
|
25
|
+
const GitRevisionPlugin = new git_revision_webpack_plugin_1.GitRevisionPlugin({ branch: true });
|
|
26
26
|
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
|
|
27
27
|
const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000');
|
|
28
28
|
const useTypeScript = true;
|
|
@@ -57,7 +57,9 @@ exports.default = (webpackEnv, paths, options = {}) => {
|
|
|
57
57
|
output: {
|
|
58
58
|
path: isEnvProduction ? paths.appBuild : undefined,
|
|
59
59
|
pathinfo: isEnvDevelopment,
|
|
60
|
-
filename: isEnvProduction
|
|
60
|
+
filename: isEnvProduction
|
|
61
|
+
? 'static/js/[name].[contenthash:8].js'
|
|
62
|
+
: isEnvDevelopment && 'static/js/[name].bundle.js',
|
|
61
63
|
chunkFilename: isEnvProduction
|
|
62
64
|
? 'static/js/[name].[contenthash:8].chunk.js'
|
|
63
65
|
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
|
@@ -131,10 +133,7 @@ exports.default = (webpackEnv, paths, options = {}) => {
|
|
|
131
133
|
tls: false,
|
|
132
134
|
child_process: false,
|
|
133
135
|
},
|
|
134
|
-
plugins: [
|
|
135
|
-
new ModuleScopePlugin_1.default(paths.appSrc, [paths.appPackageJson]),
|
|
136
|
-
new tsconfig_paths_webpack_plugin_1.default(),
|
|
137
|
-
],
|
|
136
|
+
plugins: [new ModuleScopePlugin_1.default(paths.appSrc, [paths.appPackageJson]), new tsconfig_paths_webpack_plugin_1.default()],
|
|
138
137
|
},
|
|
139
138
|
module: {
|
|
140
139
|
strictExportPresence: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.config.js","sourceRoot":"","sources":["../../src/config/webpack.config.js"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAExB,oGAAwE;AACxE,2FAAmE;AACnE,2FAAmE;AACnE,yFAAiE;AACjE,mFAA2D;AAC3D,wGAA6E;AAC7E,8GAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"webpack.config.js","sourceRoot":"","sources":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AAC,CAAC,CAAC;oBAC1F,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;gBAChE,CAAC;aACF,CAAC;YACF,8EAA8E;YAC9E,IAAI,iBAAO,CAAC,YAAY,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;YACtF,aAAa;gBACX,IAAI,wCAA0B,CAAC;oBAC7B,KAAK,EAAE,gBAAgB;oBACvB,UAAU,EAAE;wBACV,cAAc,EAAE,iBAAO,CAAC,IAAI,CAAC,YAAY,EAAE;4BACzC,OAAO,EAAE,KAAK,CAAC,cAAc;yBAC9B,CAAC;wBACF,UAAU,EAAE,KAAK,CAAC,WAAW;wBAC7B,iBAAiB,EAAE;4BACjB,QAAQ,EAAE,IAAI;4BACd,SAAS,EAAE,IAAI;yBAChB;qBACF;iBACF,CAAC;SACL,CAAC,MAAM,CAAC,OAAO,CAAC;QACjB,WAAW,EAAE,KAAK;KACnB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the absolute path to a dependency's CLI entrypoint as declared
|
|
3
|
+
* in its `package.json#bin`. Works for packages whose `exports` map
|
|
4
|
+
* blocks `require.resolve('<pkg>/bin/...')` (e.g. eslint 9+).
|
|
5
|
+
*
|
|
6
|
+
* @param pkgName - dependency name (e.g. `'eslint'`, `'prettier'`)
|
|
7
|
+
* @param binName - bin name when `package.json#bin` is an object map.
|
|
8
|
+
* Defaults to `pkgName`.
|
|
9
|
+
* @param fromPath - directory to resolve `pkgName` from. Defaults to
|
|
10
|
+
* this file's directory so production calls walk up from
|
|
11
|
+
* `@apollion-dsi/scripts`'s install location.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveBin(pkgName: string, binName?: string, fromPath?: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveBin = resolveBin;
|
|
7
|
+
const module_1 = require("module");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the absolute path to a dependency's CLI entrypoint as declared
|
|
11
|
+
* in its `package.json#bin`. Works for packages whose `exports` map
|
|
12
|
+
* blocks `require.resolve('<pkg>/bin/...')` (e.g. eslint 9+).
|
|
13
|
+
*
|
|
14
|
+
* @param pkgName - dependency name (e.g. `'eslint'`, `'prettier'`)
|
|
15
|
+
* @param binName - bin name when `package.json#bin` is an object map.
|
|
16
|
+
* Defaults to `pkgName`.
|
|
17
|
+
* @param fromPath - directory to resolve `pkgName` from. Defaults to
|
|
18
|
+
* this file's directory so production calls walk up from
|
|
19
|
+
* `@apollion-dsi/scripts`'s install location.
|
|
20
|
+
*/
|
|
21
|
+
function resolveBin(pkgName, binName = pkgName, fromPath = __dirname) {
|
|
22
|
+
const req = (0, module_1.createRequire)(path_1.default.join(fromPath, 'noop.js'));
|
|
23
|
+
const pkgJsonPath = req.resolve(`${pkgName}/package.json`);
|
|
24
|
+
const pkgJson = req(pkgJsonPath);
|
|
25
|
+
const binField = pkgJson.bin;
|
|
26
|
+
if (!binField) {
|
|
27
|
+
throw new Error(`Package "${pkgName}" has no "bin" field in package.json`);
|
|
28
|
+
}
|
|
29
|
+
const relBin = typeof binField === 'string' ? binField : binField[binName];
|
|
30
|
+
if (!relBin) {
|
|
31
|
+
throw new Error(`Package "${pkgName}" has no bin named "${binName}"`);
|
|
32
|
+
}
|
|
33
|
+
return path_1.default.resolve(path_1.default.dirname(pkgJsonPath), relBin);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=resolveBin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveBin.js","sourceRoot":"","sources":["../../src/utils/resolveBin.ts"],"names":[],"mappings":";;;;;AAeA,gCAoBC;AAnCD,mCAAuC;AACvC,gDAAwB;AAExB;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CAAC,OAAe,EAAE,UAAkB,OAAO,EAAE,WAAmB,SAAS;IACjG,MAAM,GAAG,GAAG,IAAA,sBAAa,EAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAE1D,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,OAAO,eAAe,CAAC,CAAC;IAE3D,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,CAA8C,CAAC;IAE9E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAE7B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,sCAAsC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE3E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,uBAAuB,OAAO,GAAG,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -15,11 +15,31 @@ behind four commands: `create`, `dev`, `build`, `test`.
|
|
|
15
15
|
| `dev` | webpack-dev-server + HMR (react-refresh) at :3000 |
|
|
16
16
|
| `build` | Production bundle to `build/` |
|
|
17
17
|
| `test` | Jest 30 in watch mode against changed files |
|
|
18
|
+
| `lint` | ESLint over `src` w/ Apollion config (alias for `eslint src --ext ts,tsx --quiet`) |
|
|
19
|
+
| `prettier` | Prettier `--check` over `src/**/*.{ts,tsx,json,css,md}` |
|
|
20
|
+
| `check-types` (alias `tsc`) | `tsc --noEmit` against the consumer's tsconfig |
|
|
21
|
+
| `audit` | `yarn npm audit --severity moderate --no-deprecations` (falls back to `npm audit --audit-level=moderate`) |
|
|
22
|
+
| `validate` | Pre-merge gate: `check-types` + `prettier` + `lint` in parallel, then `test --watchAll=false`. `--skip=lint,prettier` to drop steps. |
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
Every command accepts pass-through args — `scripts lint -- --fix`,
|
|
25
|
+
`scripts prettier -- --write src/`, `scripts check-types -- -p tsconfig.build.json`, etc.
|
|
26
|
+
|
|
27
|
+
Use via `package.json#scripts` — the whole consumer file becomes thin:
|
|
20
28
|
|
|
21
29
|
```json
|
|
22
|
-
{
|
|
30
|
+
{
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "scripts dev",
|
|
33
|
+
"build": "scripts build",
|
|
34
|
+
"test": "scripts test",
|
|
35
|
+
"lint": "scripts lint",
|
|
36
|
+
"lint:fix": "scripts lint -- --fix",
|
|
37
|
+
"prettier": "scripts prettier",
|
|
38
|
+
"check-types": "scripts check-types",
|
|
39
|
+
"audit-dependencies": "scripts audit",
|
|
40
|
+
"validate": "scripts validate"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
23
43
|
```
|
|
24
44
|
|
|
25
45
|
## Stack (hidden from consumer)
|
|
@@ -28,19 +48,48 @@ Use via `package.json#scripts`:
|
|
|
28
48
|
- `babel-plugin-relay` + `babel-plugin-styled-components`
|
|
29
49
|
- `react-refresh` for HMR
|
|
30
50
|
- Jest 30 + ts-jest + `@testing-library/react`
|
|
51
|
+
- ESLint 9 (`@apollion-dsi/eslint-config`) + Prettier 3
|
|
31
52
|
- Peer: **TypeScript 6.x**
|
|
32
53
|
|
|
54
|
+
Consumers pull *only* `@apollion-dsi/scripts` for tooling — eslint, prettier,
|
|
55
|
+
jest, babel et al. arrive transitively. The consumer's `package.json#scripts`
|
|
56
|
+
should only reference `scripts <cmd>`.
|
|
57
|
+
|
|
33
58
|
## Invariants
|
|
34
59
|
|
|
35
60
|
* **Yarn only** (consumer template uses Yarn 4 Berry).
|
|
36
61
|
* **No webpack config exposed.** If you need a config escape hatch,
|
|
37
62
|
open a ROADMAP entry — the point of this package is to not have one.
|
|
38
63
|
* **TypeScript 6 strict** in the template — non-negotiable.
|
|
64
|
+
* **Template tsconfig modern, never legacy.** `target: es2020`,
|
|
65
|
+
`moduleResolution: bundler`, `jsx: react-jsx`. No `es5`, no `node10`,
|
|
66
|
+
no classic JSX — both warn under TS 6.0 (`TS5107`) and break in TS 7.
|
|
67
|
+
|
|
68
|
+
## tsconfig.base.json (consumer-facing)
|
|
69
|
+
|
|
70
|
+
`@apollion-dsi/scripts` exposes a modern TS base config. Consumers
|
|
71
|
+
extend it instead of copying values:
|
|
72
|
+
|
|
73
|
+
```jsonc
|
|
74
|
+
// tsconfig.json
|
|
75
|
+
{
|
|
76
|
+
"extends": "@apollion-dsi/scripts/tsconfig.base.json",
|
|
77
|
+
"include": ["src"]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The base sets `target: es2020`, `module: esnext`,
|
|
82
|
+
`moduleResolution: bundler`, `jsx: react-jsx` (automatic runtime — no
|
|
83
|
+
`import React` needed for JSX), `strict`, `isolatedModules`,
|
|
84
|
+
`noEmit`. Overriding any field is fine; the goal is a defaultful SSOT,
|
|
85
|
+
not a lock-in.
|
|
39
86
|
|
|
40
87
|
## Files
|
|
41
88
|
|
|
42
89
|
- `lib/bin.js` — CLI entry (resolved by `package.json#bin`).
|
|
43
90
|
- `lib/index.js` — programmatic entry.
|
|
91
|
+
- `tsconfig.base.json` — exported via `package.json#exports` for
|
|
92
|
+
consumer `extends`.
|
|
44
93
|
- `src/` — TS sources.
|
|
45
94
|
- `scripts/validate.sh` — workspace `validate` step.
|
|
46
95
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollion-dsi/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Apollion Framework CLI",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": "lib/bin.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./tsconfig.base.json": "./tsconfig.base.json",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
7
12
|
"scripts": {
|
|
8
13
|
"prepare": "yarn build",
|
|
9
14
|
"audit-dependencies": "yarn npm audit --severity moderate --no-deprecations",
|
|
@@ -18,7 +23,8 @@
|
|
|
18
23
|
"test:watch": "jest --watch",
|
|
19
24
|
"coverage": "jest --coverage",
|
|
20
25
|
"validate:tests": "jest --coverage",
|
|
21
|
-
"build": "tsc -p ."
|
|
26
|
+
"build": "tsc -p .",
|
|
27
|
+
"release": "yarn build && yarn changeset publish"
|
|
22
28
|
},
|
|
23
29
|
"keywords": [],
|
|
24
30
|
"author": "Apollion DS Team",
|
|
@@ -46,6 +52,7 @@
|
|
|
46
52
|
"detect-port": "2.1.0",
|
|
47
53
|
"dotenv": "17.4.2",
|
|
48
54
|
"dotenv-expand": "13.0.0",
|
|
55
|
+
"eslint": "9.29.0",
|
|
49
56
|
"fork-ts-checker-webpack-plugin": "9.1.0",
|
|
50
57
|
"fs-extra": "11.3.5",
|
|
51
58
|
"git-revision-webpack-plugin": "5.0.0",
|
|
@@ -55,6 +62,7 @@
|
|
|
55
62
|
"jest": "30.4.2",
|
|
56
63
|
"jest-cli": "30.4.2",
|
|
57
64
|
"jest-environment-node": "^30.4.1",
|
|
65
|
+
"prettier": "3.8.3",
|
|
58
66
|
"react-refresh": "0.18.0",
|
|
59
67
|
"resolve": "1.22.12",
|
|
60
68
|
"semver": "7.8.0",
|
|
@@ -73,9 +81,7 @@
|
|
|
73
81
|
"devDependencies": {
|
|
74
82
|
"@testing-library/dom": "10.4.1",
|
|
75
83
|
"@types/jest": "30.0.0",
|
|
76
|
-
"eslint": "9.29.0",
|
|
77
84
|
"npm-run-all": "4.1.5",
|
|
78
|
-
"prettier": "3.8.3",
|
|
79
85
|
"react": "19.2.6",
|
|
80
86
|
"react-dom": "19.2.6",
|
|
81
87
|
"styled-components": "6.4.1",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import { resolveBin } from '../utils/resolveBin';
|
|
6
|
+
|
|
7
|
+
describe('resolveBin', () => {
|
|
8
|
+
let tmpRoot: string;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
tmpRoot = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'apollion-scripts-resolveBin-')));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function makeFakePkg(name: string, binField: unknown, binFiles: string[] = []): void {
|
|
19
|
+
const pkgDir = path.join(tmpRoot, 'node_modules', name);
|
|
20
|
+
fs.mkdirSync(pkgDir, { recursive: true });
|
|
21
|
+
fs.writeFileSync(path.join(pkgDir, 'package.json'), JSON.stringify({ name, version: '0.0.0', bin: binField }));
|
|
22
|
+
|
|
23
|
+
for (const file of binFiles) {
|
|
24
|
+
const target = path.join(pkgDir, file);
|
|
25
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
26
|
+
fs.writeFileSync(target, '#!/usr/bin/env node\n');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
it('resolves a string-style bin field', () => {
|
|
31
|
+
makeFakePkg('faketool-a', './bin/cli.js', ['bin/cli.js']);
|
|
32
|
+
|
|
33
|
+
const resolved = resolveBin('faketool-a', 'faketool-a', tmpRoot);
|
|
34
|
+
|
|
35
|
+
expect(resolved).toBe(path.join(tmpRoot, 'node_modules', 'faketool-a', 'bin', 'cli.js'));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('resolves a map-style bin field via the pkg name by default', () => {
|
|
39
|
+
makeFakePkg('faketool-b', { 'faketool-b': './bin/main.js', other: './bin/other.js' }, [
|
|
40
|
+
'bin/main.js',
|
|
41
|
+
'bin/other.js',
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const resolved = resolveBin('faketool-b', 'faketool-b', tmpRoot);
|
|
45
|
+
|
|
46
|
+
expect(resolved).toBe(path.join(tmpRoot, 'node_modules', 'faketool-b', 'bin', 'main.js'));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('resolves a map-style bin field via an explicit alternative name', () => {
|
|
50
|
+
makeFakePkg('faketool-c', { 'faketool-c': './bin/main.js', alt: './bin/alt.js' }, ['bin/main.js', 'bin/alt.js']);
|
|
51
|
+
|
|
52
|
+
const resolved = resolveBin('faketool-c', 'alt', tmpRoot);
|
|
53
|
+
|
|
54
|
+
expect(resolved).toBe(path.join(tmpRoot, 'node_modules', 'faketool-c', 'bin', 'alt.js'));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('throws if the package has no bin field', () => {
|
|
58
|
+
makeFakePkg('faketool-d', undefined);
|
|
59
|
+
|
|
60
|
+
expect(() => resolveBin('faketool-d', 'faketool-d', tmpRoot)).toThrow(/no "bin" field/);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('throws if the requested bin name is missing from the map', () => {
|
|
64
|
+
makeFakePkg('faketool-e', { 'faketool-e': './bin/main.js' }, ['bin/main.js']);
|
|
65
|
+
|
|
66
|
+
expect(() => resolveBin('faketool-e', 'missing', tmpRoot)).toThrow(/no bin named "missing"/);
|
|
67
|
+
});
|
|
68
|
+
});
|
package/src/bin.ts
CHANGED
|
@@ -18,10 +18,18 @@ notifier.notify({
|
|
|
18
18
|
)} \nRun ${chalk.cyan('yarn add {packageName}')} to update.`,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
const COMMAND_ALIASES: Record<string, string> = {
|
|
22
|
+
tsc: 'check-types',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const SUPPORTED_COMMANDS = new Set(['build', 'dev', 'test', 'lint', 'prettier', 'check-types', 'audit', 'validate']);
|
|
26
|
+
|
|
21
27
|
(async (cmd: string[]) => {
|
|
22
|
-
const [
|
|
28
|
+
const [rawCommand, ...options] = cmd;
|
|
29
|
+
|
|
30
|
+
const command = COMMAND_ALIASES[rawCommand] ?? rawCommand;
|
|
23
31
|
|
|
24
|
-
if (
|
|
32
|
+
if (SUPPORTED_COMMANDS.has(command)) {
|
|
25
33
|
const result = spawn.sync(process.execPath, [require.resolve(`./command/${command}`), ...options], {
|
|
26
34
|
stdio: 'inherit',
|
|
27
35
|
});
|
|
@@ -35,7 +43,7 @@ notifier.notify({
|
|
|
35
43
|
return process.exit(0);
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
console.log(`${chalk.red('Commando não reconhecido:')} ${chalk.yellow(
|
|
46
|
+
console.log(`${chalk.red('Commando não reconhecido:')} ${chalk.yellow(rawCommand)}`);
|
|
39
47
|
|
|
40
48
|
process.exit(1);
|
|
41
49
|
})(process.argv.slice(2));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `scripts audit` — delegates to the active package manager's audit
|
|
5
|
+
* command. Defaults match the Apollion ecosystem standard
|
|
6
|
+
* (`severity moderate`, no deprecation noise). User-supplied args are
|
|
7
|
+
* appended.
|
|
8
|
+
*
|
|
9
|
+
* Resolution order:
|
|
10
|
+
* 1. yarn berry (>=2) — `yarn npm audit --severity moderate --no-deprecations`
|
|
11
|
+
* 2. yarn classic (1.x) — `yarn audit --level moderate`
|
|
12
|
+
* 3. npm fallback — `npm audit --audit-level=moderate`
|
|
13
|
+
*/
|
|
14
|
+
function probeYarnMajor(): number | null {
|
|
15
|
+
const probe = spawn.sync('yarn', ['--version'], { encoding: 'utf8' });
|
|
16
|
+
|
|
17
|
+
if (probe.status !== 0 || !probe.stdout) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const major = Number.parseInt(String(probe.stdout).trim().split('.')[0], 10);
|
|
22
|
+
|
|
23
|
+
return Number.isNaN(major) ? null : major;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const userArgs = process.argv.slice(2);
|
|
27
|
+
|
|
28
|
+
const yarnMajor = probeYarnMajor();
|
|
29
|
+
|
|
30
|
+
let command: string;
|
|
31
|
+
let baseArgs: string[];
|
|
32
|
+
|
|
33
|
+
if (yarnMajor !== null && yarnMajor >= 2) {
|
|
34
|
+
command = 'yarn';
|
|
35
|
+
baseArgs = ['npm', 'audit', '--severity', 'moderate', '--no-deprecations'];
|
|
36
|
+
} else if (yarnMajor !== null) {
|
|
37
|
+
command = 'yarn';
|
|
38
|
+
baseArgs = ['audit', '--level', 'moderate'];
|
|
39
|
+
} else {
|
|
40
|
+
command = 'npm';
|
|
41
|
+
baseArgs = ['audit', '--audit-level=moderate'];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const result = spawn.sync(command, [...baseArgs, ...userArgs], { stdio: 'inherit' });
|
|
45
|
+
|
|
46
|
+
process.exit(result.status ?? 1);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
|
|
3
|
+
import { resolveBin } from '../utils/resolveBin';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `scripts check-types` (alias `scripts tsc`) — runs `tsc --noEmit`
|
|
7
|
+
* resolving the consumer's TypeScript install (peerDep). Extra args
|
|
8
|
+
* pass through verbatim.
|
|
9
|
+
*/
|
|
10
|
+
const tscBin = resolveBin('typescript', 'tsc');
|
|
11
|
+
|
|
12
|
+
const userArgs = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
const args = userArgs.length > 0 ? userArgs : ['--noEmit'];
|
|
15
|
+
|
|
16
|
+
const result = spawn.sync(process.execPath, [tscBin, ...args], { stdio: 'inherit' });
|
|
17
|
+
|
|
18
|
+
process.exit(result.status ?? 1);
|
|
@@ -81,11 +81,13 @@ async function createPackageJson(config) {
|
|
|
81
81
|
start: 'scripts dev',
|
|
82
82
|
build: 'scripts build',
|
|
83
83
|
test: 'scripts test -- --config=jest.config.js',
|
|
84
|
-
lint: '
|
|
85
|
-
'lint:
|
|
86
|
-
|
|
87
|
-
'prettier:write': 'prettier
|
|
88
|
-
'
|
|
84
|
+
lint: 'scripts lint',
|
|
85
|
+
'lint:fix': 'scripts lint --fix',
|
|
86
|
+
prettier: 'scripts prettier',
|
|
87
|
+
'prettier:write': 'scripts prettier --write',
|
|
88
|
+
'check-types': 'scripts check-types',
|
|
89
|
+
'audit-dependencies': 'scripts audit',
|
|
90
|
+
validate: 'scripts validate',
|
|
89
91
|
},
|
|
90
92
|
husky: {
|
|
91
93
|
hooks: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
|
|
3
|
+
import { resolveBin } from '../utils/resolveBin';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `scripts lint` — ESLint over `src` with `--quiet`. ESLint 9 flat
|
|
7
|
+
* config uses `eslint.config.js#files` for filtering (no `--ext`).
|
|
8
|
+
*
|
|
9
|
+
* If the consumer passes any path-like arg, they own the invocation
|
|
10
|
+
* entirely. Flag-only invocations (e.g. `scripts lint --fix`) keep the
|
|
11
|
+
* default `src` target so the common case Just Works.
|
|
12
|
+
*/
|
|
13
|
+
const eslintBin = resolveBin('eslint');
|
|
14
|
+
|
|
15
|
+
const userArgs = process.argv.slice(2);
|
|
16
|
+
|
|
17
|
+
const userProvidedPath = userArgs.some((a) => !a.startsWith('-'));
|
|
18
|
+
|
|
19
|
+
let args: string[];
|
|
20
|
+
|
|
21
|
+
if (userArgs.length === 0) {
|
|
22
|
+
args = ['src', '--quiet'];
|
|
23
|
+
} else if (userProvidedPath) {
|
|
24
|
+
args = userArgs;
|
|
25
|
+
} else {
|
|
26
|
+
args = [...userArgs, 'src'];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const result = spawn.sync(process.execPath, [eslintBin, ...args], { stdio: 'inherit' });
|
|
30
|
+
|
|
31
|
+
process.exit(result.status ?? 1);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
|
|
3
|
+
import { resolveBin } from '../utils/resolveBin';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `scripts prettier` — `--check` over `src/**\/*.{ts,tsx,json,css,md}`.
|
|
7
|
+
*
|
|
8
|
+
* Flag-only user args (e.g. `scripts prettier --write`) keep the default
|
|
9
|
+
* glob so `--write` is enough. A path-like arg switches to fully
|
|
10
|
+
* user-controlled invocation.
|
|
11
|
+
*/
|
|
12
|
+
const prettierBin = resolveBin('prettier');
|
|
13
|
+
|
|
14
|
+
const DEFAULT_GLOB = 'src/**/*.{ts,tsx,json,css,md}';
|
|
15
|
+
|
|
16
|
+
const userArgs = process.argv.slice(2);
|
|
17
|
+
|
|
18
|
+
const userProvidedPath = userArgs.some((a) => !a.startsWith('-'));
|
|
19
|
+
|
|
20
|
+
let args: string[];
|
|
21
|
+
|
|
22
|
+
if (userArgs.length === 0) {
|
|
23
|
+
args = ['--check', DEFAULT_GLOB];
|
|
24
|
+
} else if (userProvidedPath) {
|
|
25
|
+
args = userArgs;
|
|
26
|
+
} else {
|
|
27
|
+
args = [...userArgs, DEFAULT_GLOB];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const result = spawn.sync(process.execPath, [prettierBin, ...args], { stdio: 'inherit' });
|
|
31
|
+
|
|
32
|
+
process.exit(result.status ?? 1);
|
package/src/command/test.ts
CHANGED
|
@@ -10,7 +10,7 @@ require('../config/env');
|
|
|
10
10
|
|
|
11
11
|
import { execSync } from 'child_process';
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import { run as jestRun } from 'jest-cli';
|
|
14
14
|
|
|
15
15
|
const argv = process.argv.slice(2);
|
|
16
16
|
|
|
@@ -30,4 +30,4 @@ if (!process.env.CI && argv.indexOf('--watchAll') === -1 && argv.indexOf('--watc
|
|
|
30
30
|
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
jestRun(argv);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import spawn from 'cross-spawn';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `scripts validate` — Apollion's standard pre-merge gate. Runs
|
|
6
|
+
* `check-types`, `prettier --check`, `lint` (parallel) then `test`
|
|
7
|
+
* with `--watchAll=false` (sequential). Bails on the first failure.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors the Apollion ecosystem's own `scripts/validate.sh`
|
|
10
|
+
* orchestration so consumers don't have to reinvent it.
|
|
11
|
+
*/
|
|
12
|
+
const userArgs = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
const skip = new Set(
|
|
15
|
+
userArgs.filter((arg) => arg.startsWith('--skip=')).flatMap((arg) => arg.slice('--skip='.length).split(',')),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
type Step = { name: string; cmd: string };
|
|
19
|
+
|
|
20
|
+
const parallel: Step[] = [
|
|
21
|
+
{ name: 'check-types', cmd: 'check-types' },
|
|
22
|
+
{ name: 'prettier', cmd: 'prettier' },
|
|
23
|
+
{ name: 'lint', cmd: 'lint' },
|
|
24
|
+
].filter((s) => !skip.has(s.name));
|
|
25
|
+
|
|
26
|
+
const sequential: Step[] = [{ name: 'test', cmd: 'test --watchAll=false' }].filter((s) => !skip.has(s.name));
|
|
27
|
+
|
|
28
|
+
function runStep(step: Step): Promise<number> {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
console.log(chalk.cyan(`▶ ${step.name}`));
|
|
31
|
+
|
|
32
|
+
const [bin, ...rest] = step.cmd.split(' ');
|
|
33
|
+
|
|
34
|
+
const child = spawn(process.execPath, [require.resolve(`./${bin}`), ...rest], {
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
child.on('close', (code) => resolve(code ?? 1));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
(async () => {
|
|
43
|
+
const parallelResults = await Promise.all(parallel.map(runStep));
|
|
44
|
+
|
|
45
|
+
const parallelFailures = parallel.filter((_, i) => parallelResults[i] !== 0);
|
|
46
|
+
|
|
47
|
+
if (parallelFailures.length > 0) {
|
|
48
|
+
console.error(chalk.red(`✘ validate failed: ${parallelFailures.map((s) => s.name).join(', ')}`));
|
|
49
|
+
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (const step of sequential) {
|
|
54
|
+
const code = await runStep(step);
|
|
55
|
+
|
|
56
|
+
if (code !== 0) {
|
|
57
|
+
console.error(chalk.red(`✘ validate failed: ${step.name}`));
|
|
58
|
+
|
|
59
|
+
process.exit(code);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log(chalk.green('✓ validate passed'));
|
|
64
|
+
|
|
65
|
+
process.exit(0);
|
|
66
|
+
})();
|
|
@@ -7,7 +7,7 @@ import ModuleNotFoundPlugin from '../utils/ModuleNotFoundPlugin';
|
|
|
7
7
|
import ModuleScopePlugin from '../utils/ModuleScopePlugin';
|
|
8
8
|
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
|
9
9
|
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
|
|
10
|
-
import
|
|
10
|
+
import { GitRevisionPlugin as GitRevisionPluginCtor } from 'git-revision-webpack-plugin';
|
|
11
11
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
12
12
|
import resolve from 'resolve';
|
|
13
13
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
@@ -21,7 +21,7 @@ import modules from './modules';
|
|
|
21
21
|
export default (webpackEnv, paths, options = {}) => {
|
|
22
22
|
const appPackageJson = require(paths.appPackageJson);
|
|
23
23
|
|
|
24
|
-
const GitRevisionPlugin = new
|
|
24
|
+
const GitRevisionPlugin = new GitRevisionPluginCtor({ branch: true });
|
|
25
25
|
|
|
26
26
|
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
|
|
27
27
|
|
|
@@ -64,7 +64,9 @@ export default (webpackEnv, paths, options = {}) => {
|
|
|
64
64
|
output: {
|
|
65
65
|
path: isEnvProduction ? paths.appBuild : undefined,
|
|
66
66
|
pathinfo: isEnvDevelopment,
|
|
67
|
-
filename: isEnvProduction
|
|
67
|
+
filename: isEnvProduction
|
|
68
|
+
? 'static/js/[name].[contenthash:8].js'
|
|
69
|
+
: isEnvDevelopment && 'static/js/[name].bundle.js',
|
|
68
70
|
chunkFilename: isEnvProduction
|
|
69
71
|
? 'static/js/[name].[contenthash:8].chunk.js'
|
|
70
72
|
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
|
@@ -138,10 +140,7 @@ export default (webpackEnv, paths, options = {}) => {
|
|
|
138
140
|
tls: false,
|
|
139
141
|
child_process: false,
|
|
140
142
|
},
|
|
141
|
-
plugins: [
|
|
142
|
-
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
|
143
|
-
new TsconfigPathsPlugin(),
|
|
144
|
-
],
|
|
143
|
+
plugins: [new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), new TsconfigPathsPlugin()],
|
|
145
144
|
},
|
|
146
145
|
module: {
|
|
147
146
|
strictExportPresence: true,
|