@skathi-native/cli 0.0.0-stage → 0.1.0-beta.1
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/aot-inputs.ts +294 -0
- package/ascii.ts +397 -0
- package/build.ts +1236 -0
- package/check/builtins.json +1219 -0
- package/check/builtins.ts +112 -0
- package/check/codes.ts +178 -0
- package/check/command.ts +105 -0
- package/check/config.ts +76 -0
- package/check/finding.ts +30 -0
- package/check/graph.ts +69 -0
- package/check/highlight.ts +40 -0
- package/check/index.ts +308 -0
- package/check/packages.ts +54 -0
- package/check/program.ts +209 -0
- package/check/report.ts +219 -0
- package/check/rules.ts +307 -0
- package/check/schema.ts +69 -0
- package/check/typing.ts +703 -0
- package/cli/assets.ts +114 -0
- package/cli/build-app.ts +587 -0
- package/cli/config.ts +646 -0
- package/cli/create.ts +411 -0
- package/cli/dev.ts +92 -0
- package/cli/elf.ts +142 -0
- package/cli/host-fetch.ts +178 -0
- package/cli/host.ts +378 -0
- package/cli/icon.ts +303 -0
- package/cli/macos-bundle.ts +451 -0
- package/cli/pe.ts +429 -0
- package/cli/platform.ts +74 -0
- package/cli/sk.ts +356 -0
- package/cli/skpk.ts +268 -0
- package/cli/stamp.ts +254 -0
- package/cli/term.ts +176 -0
- package/cli/versioninfo.ts +123 -0
- package/css-prefixes.ts +118 -0
- package/devtools/apps.ts +68 -0
- package/devtools/commands.ts +860 -0
- package/devtools/ctl.ts +166 -0
- package/package.json +58 -4
- package/prod.ts +701 -0
- package/runtime-path.ts +24 -0
- package/tailwind.ts +76 -0
- package/vitecompat.ts +1151 -0
- package/README.md +0 -3
package/runtime-path.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join, sep } from "node:path";
|
|
4
|
+
|
|
5
|
+
/** The `@skathi-native/runtime` package the builders bundle into every app. */
|
|
6
|
+
export const RUNTIME_DIR = realpathSync(
|
|
7
|
+
dirname(createRequire(import.meta.path).resolve("@skathi-native/runtime/package.json")),
|
|
8
|
+
);
|
|
9
|
+
export const RUNTIME_SRC_DIR = join(RUNTIME_DIR, "src");
|
|
10
|
+
export const RUNTIME_ENTRY = join(RUNTIME_SRC_DIR, "runtime.ts");
|
|
11
|
+
export const LOADER_ENTRY = join(RUNTIME_SRC_DIR, "loader.ts");
|
|
12
|
+
/** Resolves from the runtime package: its own vue-router and pinia, for an app that declares neither. */
|
|
13
|
+
export const runtimeRequire = createRequire(join(RUNTIME_DIR, "package.json"));
|
|
14
|
+
|
|
15
|
+
/** The node_modules the runtime's dependencies are installed in (hoisted to the workspace root in a checkout). */
|
|
16
|
+
export const RUNTIME_MODULES_DIR = (() => {
|
|
17
|
+
const dep = realpathSync(runtimeRequire.resolve("@vue/runtime-core"));
|
|
18
|
+
const at = dep.lastIndexOf(`${sep}node_modules${sep}`);
|
|
19
|
+
return at < 0 ? join(RUNTIME_DIR, "node_modules") : dep.slice(0, at + `${sep}node_modules`.length);
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
/** Bare specifiers the builders serve from the runtime; an app cannot alias them. */
|
|
23
|
+
export const PRESEEDED: readonly string[] = ["vue", "@skathi-native/runtime", "vue-router", "pinia"];
|
|
24
|
+
export const isPreseeded = (spec: string) => PRESEEDED.includes(spec);
|
package/tailwind.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Tailwind CSS integration, shared by build.ts (dev) and prod.ts.
|
|
2
|
+
//
|
|
3
|
+
// Pinned to v3.4 (package.json): v4 emits `calc(var(--spacing) * 4)`, `color-mix`, `@property`,
|
|
4
|
+
// `@layer` and `@theme`, which sk-css cannot resolve completely yet; v3.4 emits literal
|
|
5
|
+
// declarations that render.
|
|
6
|
+
//
|
|
7
|
+
// We ask for `@tailwind base; @tailwind utilities`, not `components`. `base` carries the
|
|
8
|
+
// `*, ::before, ::after { --tw-*: … }` seeds that make compound utilities (shadows, rings,
|
|
9
|
+
// transforms, `space-*`) resolve; its ::before/::after halves are dropped with one advisory.
|
|
10
|
+
|
|
11
|
+
import { existsSync } from "fs";
|
|
12
|
+
import { dirname, join, resolve as resolvePath } from "path";
|
|
13
|
+
|
|
14
|
+
import postcss from "postcss";
|
|
15
|
+
import tailwindcss from "tailwindcss";
|
|
16
|
+
|
|
17
|
+
/// The synthetic module id the utilities sheet rides on. A leading "." sorts first, so utilities
|
|
18
|
+
/// land before component <style> and lose specificity ties, as in a browser project.
|
|
19
|
+
export const TW_ID = ".sk/tailwind.css";
|
|
20
|
+
|
|
21
|
+
const CONFIG_NAMES = ["tailwind.config.js", "tailwind.config.cjs", "tailwind.config.mjs", "tailwind.config.ts"];
|
|
22
|
+
|
|
23
|
+
/// Nearest `tailwind.config.*` at or above `startDir`, stopping after `stopDir` (the workspace root).
|
|
24
|
+
/// `null`: the app opts out and no synthetic module is emitted.
|
|
25
|
+
export function findConfig(startDir: string, stopDir: string): string | null {
|
|
26
|
+
let dir = startDir;
|
|
27
|
+
for (;;) {
|
|
28
|
+
for (const name of CONFIG_NAMES) {
|
|
29
|
+
const candidate = join(dir, name);
|
|
30
|
+
if (existsSync(candidate)) return candidate;
|
|
31
|
+
}
|
|
32
|
+
if (dir === stopDir) return null;
|
|
33
|
+
const parent = dirname(dir);
|
|
34
|
+
if (parent === dir) return null; // filesystem root — startDir was outside stopDir
|
|
35
|
+
dir = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Runs Tailwind's JIT over the config's `content` globs and returns the utilities sheet.
|
|
40
|
+
///
|
|
41
|
+
/// Runs with the config's directory as cwd (Tailwind v3 resolves a relative `content` glob against
|
|
42
|
+
/// `process.cwd()`); calls are serialized because cwd is process-global.
|
|
43
|
+
export function generate(configPath: string, source?: CssSource): Promise<string> {
|
|
44
|
+
const run = async () => {
|
|
45
|
+
const dir = dirname(configPath);
|
|
46
|
+
const prev = process.cwd();
|
|
47
|
+
const move = resolvePath(prev).toLowerCase() !== resolvePath(dir).toLowerCase();
|
|
48
|
+
if (move) process.chdir(dir);
|
|
49
|
+
try {
|
|
50
|
+
const result = await postcss([tailwindcss(configPath)]).process(
|
|
51
|
+
source?.text ?? "@tailwind base;\n@tailwind utilities;\n",
|
|
52
|
+
{ from: source?.from },
|
|
53
|
+
);
|
|
54
|
+
return result.css;
|
|
55
|
+
} finally {
|
|
56
|
+
if (move) process.chdir(prev);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const next = queue.then(run, run);
|
|
60
|
+
queue = next.catch(() => undefined);
|
|
61
|
+
return next;
|
|
62
|
+
}
|
|
63
|
+
let queue: Promise<unknown> = Promise.resolve();
|
|
64
|
+
|
|
65
|
+
/// A stylesheet the app owns, handed to Tailwind as its own entry so `@tailwind` and `@apply` expand in place.
|
|
66
|
+
export type CssSource = { text: string; from: string };
|
|
67
|
+
|
|
68
|
+
/// Does this stylesheet need Tailwind's PostCSS pass (`@tailwind` / `@layer` / `@apply` / `theme()`)? A plain sheet is emitted verbatim.
|
|
69
|
+
export function needsTailwindPass(css: string): boolean {
|
|
70
|
+
return /@tailwind\b|@layer\b|@apply\b|@screen\b|(?<![\w-])theme\(/.test(css);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Does this stylesheet declare the utilities layer itself? Then the synthetic `.sk/tailwind.css` module is redundant.
|
|
74
|
+
export function declaresUtilities(css: string): boolean {
|
|
75
|
+
return /@tailwind\s+utilities\s*;/.test(css);
|
|
76
|
+
}
|