@phreshos/cli 0.1.4 → 0.1.6

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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -26
  3. package/dist/build-template.js +73 -42
  4. package/dist/cli.js +135 -241
  5. package/dist/create.js +73 -80
  6. package/dist/derive.js +4 -4
  7. package/dist/init.js +113 -122
  8. package/dist/pack.js +9 -8
  9. package/dist/program-intake.js +10 -2
  10. package/dist/project-dependency.js +13 -44
  11. package/dist/project.js +2 -3
  12. package/dist/prompts.js +105 -0
  13. package/dist/style.js +9 -14
  14. package/dist/system/command.js +70 -0
  15. package/dist/system/installation.js +241 -0
  16. package/dist/system/lifecycle.js +174 -0
  17. package/dist/system/node.js +13 -0
  18. package/dist/system/paths.js +28 -0
  19. package/dist/system/process.js +23 -0
  20. package/dist/system/readiness.js +29 -0
  21. package/dist/system/release.js +86 -0
  22. package/dist/system/service/index.js +11 -0
  23. package/dist/system/service/linux.js +94 -0
  24. package/dist/system/service/macos.js +123 -0
  25. package/dist/system/types.js +0 -0
  26. package/dist/template/README.md +1 -1
  27. package/dist/template/icon.png +0 -0
  28. package/dist/template/package.json +8 -7
  29. package/dist/template/phresh.config.ts +65 -25
  30. package/dist/template/source/build.ts +3 -3
  31. package/dist/template/source/client/app.tsx +3 -8
  32. package/dist/template/source/server/main.ts +1 -1
  33. package/dist/template/vite.client.ts +22 -0
  34. package/dist/template/vite.server.ts +27 -0
  35. package/dist/template.json +5 -0
  36. package/package.json +36 -4
  37. package/dist/questions.js +0 -25
  38. package/dist/relative-value.js +0 -118
  39. package/dist/template/icons/128x128.png +0 -0
  40. package/dist/template/vite.config.ts +0 -38
@@ -1,118 +0,0 @@
1
- /**
2
- * Reduces a strict linear expression into `span * relative + pixels`.
3
- *
4
- * Numbers are absolute values. Percentages and `n/d` fractions are relative
5
- * values. Addition and subtraction combine terms; multiplication and division
6
- * scale the preceding term by a number. No arbitrary code or CSS is accepted.
7
- */
8
- export function parseRelativeValue(input) {
9
- if (typeof input === "number")
10
- return Number.isFinite(input) ? { relative: 0, pixels: clean(input) } : null;
11
- if (typeof input !== "string" || input.trim().length === 0)
12
- return null;
13
- return new Reader(input).parse();
14
- }
15
- /** Returns whether a value belongs to the linear relative-value grammar. */
16
- export function isRelativeValue(value) {
17
- return parseRelativeValue(value) !== null;
18
- }
19
- class Reader {
20
- position = 0;
21
- source;
22
- constructor(source) {
23
- this.source = source;
24
- }
25
- parse() {
26
- const value = { relative: 0, pixels: 0 };
27
- let direction = this.sign();
28
- while (this.position < this.source.length) {
29
- const term = this.term();
30
- if (!term)
31
- return null;
32
- value.relative += term.relative * direction;
33
- value.pixels += term.pixels * direction;
34
- if (!finite(value))
35
- return null;
36
- this.space();
37
- if (this.position === this.source.length)
38
- return { relative: clean(value.relative), pixels: clean(value.pixels) };
39
- const operator = this.source[this.position];
40
- if (operator !== "+" && operator !== "-")
41
- return null;
42
- this.position += 1;
43
- direction = (operator === "+" ? 1 : -1) * this.sign();
44
- }
45
- return null;
46
- }
47
- term() {
48
- const value = this.measurement();
49
- if (!value)
50
- return null;
51
- while (true) {
52
- this.space();
53
- const operator = this.source[this.position];
54
- if (operator !== "*" && operator !== "/")
55
- return value;
56
- this.position += 1;
57
- const scalar = this.scalar();
58
- if (scalar === null || operator === "/" && scalar === 0)
59
- return null;
60
- const factor = operator === "*" ? scalar : 1 / scalar;
61
- value.relative *= factor;
62
- value.pixels *= factor;
63
- if (!finite(value))
64
- return null;
65
- }
66
- }
67
- measurement() {
68
- this.space();
69
- const remainder = this.source.slice(this.position);
70
- const fraction = remainder.match(/^(\d+(?:\.\d+)?|\.\d+)\s*\/\s*(\d+(?:\.\d+)?|\.\d+)(?![\d.])/);
71
- if (fraction) {
72
- const denominator = Number(fraction[2]);
73
- if (!denominator)
74
- return null;
75
- this.position += fraction[0].length;
76
- return { relative: Number(fraction[1]) / denominator, pixels: 0 };
77
- }
78
- const percentage = remainder.match(/^(\d+(?:\.\d+)?|\.\d+)\s*%/);
79
- if (percentage) {
80
- this.position += percentage[0].length;
81
- return { relative: Number(percentage[1]) / 100, pixels: 0 };
82
- }
83
- const number = this.number();
84
- return number === null ? null : { relative: 0, pixels: number };
85
- }
86
- scalar() {
87
- const direction = this.sign();
88
- const value = this.number();
89
- return value === null ? null : value * direction;
90
- }
91
- number() {
92
- this.space();
93
- const number = this.source.slice(this.position).match(/^(\d+(?:\.\d+)?|\.\d+)/)?.[0];
94
- if (!number)
95
- return null;
96
- this.position += number.length;
97
- return Number(number);
98
- }
99
- sign() {
100
- this.space();
101
- const sign = this.source[this.position];
102
- if (sign !== "+" && sign !== "-")
103
- return 1;
104
- this.position += 1;
105
- this.space();
106
- return sign === "-" ? -1 : 1;
107
- }
108
- space() {
109
- while (/\s/.test(this.source[this.position] ?? ""))
110
- this.position += 1;
111
- }
112
- }
113
- function finite(value) {
114
- return Number.isFinite(value.relative) && Number.isFinite(value.pixels);
115
- }
116
- function clean(value) {
117
- return Object.is(value, -0) ? 0 : value;
118
- }
Binary file
@@ -1,38 +0,0 @@
1
- import packageConfig from "./package.json" with { type: "json" }
2
- import react from "@vitejs/plugin-react"
3
- import { defineConfig } from "vite"
4
- import { resolve } from "node:path"
5
-
6
- export const externalDependencies: (keyof typeof packageConfig.dependencies)[] = [
7
-
8
- // Add packages here that should NOT be bundled during server, Example: "sqlite3"
9
- ]
10
-
11
- export default defineConfig(function (config) {
12
-
13
- return {
14
- base: "./",
15
- resolve: {
16
- tsconfigPaths: true,
17
- dedupe: ["react"]
18
- },
19
- server: {
20
- cors: true,
21
- port: 5200,
22
- strictPort: true
23
- },
24
- root: config.isSsrBuild ? "source/server" : "source/client",
25
- plugins: config.isSsrBuild ? [] : [react()],
26
- ssr: {
27
- noExternal: true,
28
- external: externalDependencies
29
- },
30
- build: {
31
- emptyOutDir: true,
32
- rolldownOptions: {
33
- input: config.isSsrBuild ? "main.ts" : "index.html"
34
- },
35
- outDir: resolve(import.meta.dirname, config.isSsrBuild ? "dist/server" : "dist/client"),
36
- }
37
- }
38
- })