@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.
Files changed (62) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/coverage/clover.xml +21 -5
  3. package/coverage/coverage-final.json +2 -1
  4. package/coverage/lcov-report/config/env.ts.html +2 -2
  5. package/coverage/lcov-report/config/index.html +1 -1
  6. package/coverage/lcov-report/config/paths.ts.html +1 -1
  7. package/coverage/lcov-report/config/shared.ts.html +1 -1
  8. package/coverage/lcov-report/index.html +18 -18
  9. package/coverage/lcov-report/utils/checkRequiredFiles.ts.html +1 -1
  10. package/coverage/lcov-report/utils/formatWebpackMessages.ts.html +1 -1
  11. package/coverage/lcov-report/utils/getPublicUrlOrPath.ts.html +1 -1
  12. package/coverage/lcov-report/utils/index.html +23 -8
  13. package/coverage/lcov-report/utils/resolveBin.ts.html +193 -0
  14. package/coverage/lcov.info +34 -2
  15. package/eslint.config.js +4 -4
  16. package/lib/bin.js +8 -3
  17. package/lib/bin.js.map +1 -1
  18. package/lib/command/audit.d.ts +1 -0
  19. package/lib/command/audit.js +44 -0
  20. package/lib/command/audit.js.map +1 -0
  21. package/lib/command/check-types.d.ts +1 -0
  22. package/lib/command/check-types.js +18 -0
  23. package/lib/command/check-types.js.map +1 -0
  24. package/lib/command/create/helper.js +0 -1
  25. package/lib/command/create/helper.js.map +1 -1
  26. package/lib/command/create/index.js +7 -5
  27. package/lib/command/create/index.js.map +1 -1
  28. package/lib/command/lint.d.ts +1 -0
  29. package/lib/command/lint.js +31 -0
  30. package/lib/command/lint.js.map +1 -0
  31. package/lib/command/prettier.d.ts +1 -0
  32. package/lib/command/prettier.js +31 -0
  33. package/lib/command/prettier.js.map +1 -0
  34. package/lib/command/test.js +2 -5
  35. package/lib/command/test.js.map +1 -1
  36. package/lib/command/validate.d.ts +1 -0
  37. package/lib/command/validate.js +51 -0
  38. package/lib/command/validate.js.map +1 -0
  39. package/lib/config/webpack.config.js +6 -7
  40. package/lib/config/webpack.config.js.map +1 -1
  41. package/lib/utils/resolveBin.d.ts +13 -0
  42. package/lib/utils/resolveBin.js +35 -0
  43. package/lib/utils/resolveBin.js.map +1 -0
  44. package/llms.txt +51 -2
  45. package/package.json +10 -4
  46. package/src/__tests__/resolveBin.test.ts +68 -0
  47. package/src/bin.ts +11 -3
  48. package/src/command/audit.ts +46 -0
  49. package/src/command/check-types.ts +18 -0
  50. package/src/command/create/helper.ts +0 -1
  51. package/src/command/create/index.ts +7 -5
  52. package/src/command/lint.ts +31 -0
  53. package/src/command/prettier.ts +32 -0
  54. package/src/command/test.ts +2 -2
  55. package/src/command/validate.ts +66 -0
  56. package/src/config/webpack.config.js +6 -7
  57. package/src/utils/resolveBin.ts +36 -0
  58. package/template/src/App.tsx +5 -2
  59. package/template/src/index.tsx +8 -6
  60. package/template/tsconfig.json +3 -24
  61. package/tsconfig.base.json +19 -0
  62. 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
+ }
@@ -1,5 +1,8 @@
1
- import { ApollionProvider, Button, Flex, GlobalStyle, Text, useNotification } from '@apollion-dsi/core';
2
- import React from 'react';
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();
@@ -1,10 +1,12 @@
1
- import React from 'react';
2
- import { render } from 'react-dom';
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
3
  import { Root } from './App';
4
4
 
5
- render(
6
- <React.StrictMode>
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
- </React.StrictMode>,
9
- document.getElementById('root'),
11
+ </StrictMode>,
10
12
  );
@@ -1,25 +1,4 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": [
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
+ }
@@ -1,5 +0,0 @@
1
- {
2
- "high": true,
3
- "package-manager": "yarn",
4
- "report-type": "summary"
5
- }