@yannick-z/modulo 0.2.0 → 0.3.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 (55) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +57 -60
  3. package/bin/modulo.js +29 -19
  4. package/biome.json +34 -0
  5. package/package.json +35 -35
  6. package/rslib.config.ts +19 -19
  7. package/src/args/get-framework-name.ts +7 -7
  8. package/src/args/index.ts +16 -74
  9. package/src/args/preset.ts +16 -16
  10. package/src/cli/init.ts +10 -6
  11. package/src/cli/pack-code.ts +20 -9
  12. package/src/config/example/example-config.ts +50 -39
  13. package/src/config/example/example-externals.ts +21 -37
  14. package/src/config/index.ts +186 -16
  15. package/src/config/presets.ts +100 -0
  16. package/src/config/type.ts +34 -12
  17. package/src/index.ts +102 -10
  18. package/src/initiator/create-config-file.ts +52 -36
  19. package/src/initiator/create-project.ts +249 -0
  20. package/src/initiator/modify-scripts.ts +42 -42
  21. package/src/packer/auto-external-plugin.ts +110 -0
  22. package/src/packer/collect-modules.ts +58 -69
  23. package/src/packer/get-externals-and-tags.ts +78 -55
  24. package/src/packer/lib.ts +76 -69
  25. package/src/packer/page.ts +106 -82
  26. package/src/packer/prepare.ts +63 -57
  27. package/src/tools/cli.ts +21 -0
  28. package/src/tools/file.ts +84 -14
  29. package/src/tools/find-path-root.ts +52 -25
  30. package/src/tools/get-framework-name.ts +7 -7
  31. package/src/tools/get-ui-plugin.ts +27 -13
  32. package/src/tools/json.ts +63 -9
  33. package/src/tools/log.ts +58 -0
  34. package/src/tools/merge-user-config.ts +17 -17
  35. package/src/tools/omit-root-path.ts +17 -7
  36. package/src/tools/panic.ts +12 -8
  37. package/src/tools/string.ts +13 -2
  38. package/src/type/guard.ts +22 -3
  39. package/tsconfig.json +9 -9
  40. package/dist/index.js +0 -773
  41. package/src/args/cmd.ts +0 -16
  42. package/src/args/mode.ts +0 -38
  43. package/src/args/node_env.ts +0 -15
  44. package/src/args/target.ts +0 -44
  45. package/src/config/externals.ts +0 -70
  46. package/src/config/generate_config.ts +0 -105
  47. package/src/config/preset/alias.ts +0 -3
  48. package/src/config/preset/dev-server.ts +0 -6
  49. package/src/config/preset/dirs.ts +0 -12
  50. package/src/config/preset/html.ts +0 -19
  51. package/src/config/preset/index.ts +0 -23
  52. package/src/config/preset/libs.ts +0 -5
  53. package/src/config/preset/minify.ts +0 -24
  54. package/src/config/preset/url.ts +0 -4
  55. package/src/tools/debug-log.ts +0 -37
package/src/type/guard.ts CHANGED
@@ -1,11 +1,30 @@
1
+ import {
2
+ type EnvExternalUrl,
3
+ type ConfigExternalUrl,
4
+ type ImportExternal,
5
+ } from "../config/type.ts";
6
+
1
7
  export function is_string(data: unknown): data is string {
2
- return typeof data === "string";
8
+ return typeof data === "string";
3
9
  }
4
10
 
5
11
  export function is_true_string(data: unknown): data is string {
6
- return typeof data === "string" && !!data;
12
+ return typeof data === "string" && !!data;
7
13
  }
8
14
 
9
15
  export function is_record(data: unknown): data is Record<string, unknown> {
10
- return !!data && typeof data === "object";
16
+ return !!data && typeof data === "object";
17
+ }
18
+
19
+ export function is_env_external(data: unknown): data is EnvExternalUrl {
20
+ return is_record(data) && is_string(data.dev) && is_string(data.prd);
21
+ }
22
+
23
+ export function is_url_config(data: unknown): data is ConfigExternalUrl {
24
+ return is_env_external(data) || is_string(data);
25
+ }
26
+
27
+ export function is_import_external(data: unknown): data is ImportExternal {
28
+ // 没有global的一概作为import的依赖
29
+ return is_record(data) && is_url_config(data.url) && !is_string(data.global);
11
30
  }
package/tsconfig.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
- "compilerOptions": {
3
- "allowImportingTsExtensions": true,
4
- "allowJs": true,
5
- "noEmit": true,
6
- "outDir": "./dist",
7
- "rootDir": "./"
8
- },
9
- "extends": "../../tsconfig.base.json",
10
- "include": ["./src/**/*", "./rslib.config.ts", "./types/*"]
2
+ "compilerOptions": {
3
+ "allowImportingTsExtensions": true,
4
+ "allowJs": true,
5
+ "noEmit": true,
6
+ "outDir": "./dist",
7
+ "rootDir": "./"
8
+ },
9
+ "extends": "../../tsconfig.base.json",
10
+ "include": ["./src/**/*", "./rslib.config.ts", "./types/*"]
11
11
  }