@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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the absolute path to a dependency's CLI entrypoint as declared
|
|
6
|
+
* in its `package.json#bin`. Works for packages whose `exports` map
|
|
7
|
+
* blocks `require.resolve('<pkg>/bin/...')` (e.g. eslint 9+).
|
|
8
|
+
*
|
|
9
|
+
* @param pkgName - dependency name (e.g. `'eslint'`, `'prettier'`)
|
|
10
|
+
* @param binName - bin name when `package.json#bin` is an object map.
|
|
11
|
+
* Defaults to `pkgName`.
|
|
12
|
+
* @param fromPath - directory to resolve `pkgName` from. Defaults to
|
|
13
|
+
* this file's directory so production calls walk up from
|
|
14
|
+
* `@apollion-dsi/scripts`'s install location.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveBin(pkgName: string, binName: string = pkgName, fromPath: string = __dirname): string {
|
|
17
|
+
const req = createRequire(path.join(fromPath, 'noop.js'));
|
|
18
|
+
|
|
19
|
+
const pkgJsonPath = req.resolve(`${pkgName}/package.json`);
|
|
20
|
+
|
|
21
|
+
const pkgJson = req(pkgJsonPath) as { bin?: string | Record<string, string> };
|
|
22
|
+
|
|
23
|
+
const binField = pkgJson.bin;
|
|
24
|
+
|
|
25
|
+
if (!binField) {
|
|
26
|
+
throw new Error(`Package "${pkgName}" has no "bin" field in package.json`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const relBin = typeof binField === 'string' ? binField : binField[binName];
|
|
30
|
+
|
|
31
|
+
if (!relBin) {
|
|
32
|
+
throw new Error(`Package "${pkgName}" has no bin named "${binName}"`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return path.resolve(path.dirname(pkgJsonPath), relBin);
|
|
36
|
+
}
|
package/template/src/App.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Flex } from '@apollion-dsi/core/containers/flex';
|
|
2
|
+
import { useNotification } from '@apollion-dsi/core/containers/notification';
|
|
3
|
+
import { Button } from '@apollion-dsi/core/elements/button';
|
|
4
|
+
import { Text } from '@apollion-dsi/core/elements/text';
|
|
5
|
+
import { ApollionProvider, GlobalStyle } from '@apollion-dsi/core/themes';
|
|
3
6
|
|
|
4
7
|
function App() {
|
|
5
8
|
const { showNotification } = useNotification();
|
package/template/src/index.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { Root } from './App';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const container = document.getElementById('root');
|
|
6
|
+
if (!container) throw new Error('Root container #root not found');
|
|
7
|
+
|
|
8
|
+
createRoot(container).render(
|
|
9
|
+
<StrictMode>
|
|
7
10
|
<Root />
|
|
8
|
-
</
|
|
9
|
-
document.getElementById('root'),
|
|
11
|
+
</StrictMode>,
|
|
10
12
|
);
|
package/template/tsconfig.json
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"allowSyntheticDefaultImports": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"module": "esnext",
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"noEmit": true,
|
|
20
|
-
"jsx": "react"
|
|
21
|
-
},
|
|
22
|
-
"include": [
|
|
23
|
-
"src"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
2
|
+
"extends": "@apollion-dsi/scripts/tsconfig.base.json",
|
|
3
|
+
"include": ["src"]
|
|
4
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es2020",
|
|
5
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
6
|
+
"module": "esnext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"noEmit": true
|
|
18
|
+
}
|
|
19
|
+
}
|