naro-cli 0.7.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.
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env node
2
+ import "./chunk-K3NQKI34.js";
3
+
4
+ // ../../packages/build/src/stack.ts
5
+ import { readFile, stat } from "fs/promises";
6
+ import { join } from "path";
7
+ import {
8
+ frameworkList
9
+ } from "@vercel/frameworks";
10
+ var PRESET_STACKS = {
11
+ next: "nextjs",
12
+ "next-export": "nextjs",
13
+ astro: "astro",
14
+ sveltekit: "sveltekit-1",
15
+ nuxt: "nuxtjs",
16
+ angular: "angular",
17
+ docusaurus: "docusaurus-2",
18
+ gatsby: "gatsby",
19
+ vite: "vite",
20
+ cra: "create-react-app",
21
+ static: "static"
22
+ };
23
+ function stackForPreset(preset) {
24
+ return PRESET_STACKS[preset];
25
+ }
26
+ var STACK_SLUG_PATTERN = /^[a-z0-9-]{1,64}$/;
27
+ function localReader(root) {
28
+ return {
29
+ exists: async (path) => {
30
+ try {
31
+ await stat(join(root, path));
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ },
37
+ isFile: async (path) => {
38
+ try {
39
+ return (await stat(join(root, path))).isFile();
40
+ } catch {
41
+ return false;
42
+ }
43
+ },
44
+ readFile: (path) => readFile(join(root, path), "utf8")
45
+ };
46
+ }
47
+ async function detectorMatches(reader, { path, matchContent, matchPackage }) {
48
+ const file = path ?? "package.json";
49
+ const pattern = matchPackage ? `"(dev)?(d|D)ependencies":\\s*{[^}]*"${matchPackage}":\\s*"(.+?)"[^}]*}` : matchContent;
50
+ if (!pattern) return reader.exists(file);
51
+ if (!await reader.isFile(file)) return false;
52
+ return new RegExp(pattern, "m").test(await reader.readFile(file));
53
+ }
54
+ async function frameworkMatches(reader, framework) {
55
+ const { every, some } = framework.detectors ?? {};
56
+ if (!every && !some) return false;
57
+ if (every) {
58
+ const results = await Promise.all(
59
+ every.map((detector) => detectorMatches(reader, detector))
60
+ );
61
+ if (!results.every(Boolean)) return false;
62
+ }
63
+ if (some) {
64
+ for (const detector of some) {
65
+ if (await detectorMatches(reader, detector)) return true;
66
+ }
67
+ return false;
68
+ }
69
+ return true;
70
+ }
71
+ function removeSuperseded(matches, slug) {
72
+ const index = matches.findIndex((framework2) => framework2?.slug === slug);
73
+ const framework = matches[index];
74
+ if (!framework) return;
75
+ for (const next of framework.supersedes ?? [])
76
+ removeSuperseded(matches, next);
77
+ matches.splice(index, 1);
78
+ }
79
+ async function detectStack(root, reader = localReader(root)) {
80
+ const candidates = frameworkList.filter(
81
+ (framework) => !framework.experimental && framework.slug
82
+ );
83
+ const matches = await Promise.all(
84
+ candidates.map(
85
+ async (framework) => await frameworkMatches(reader, framework) ? framework : null
86
+ )
87
+ );
88
+ for (const match of matches.slice()) {
89
+ for (const slug2 of match?.supersedes ?? []) removeSuperseded(matches, slug2);
90
+ }
91
+ const slug = matches.find((match) => match !== null)?.slug ?? null;
92
+ if (slug === "vite") return await viteLibrary(reader) ?? "vite";
93
+ return slug && STACK_SLUG_PATTERN.test(slug) ? slug : null;
94
+ }
95
+ var VITE_LIBRARIES = [
96
+ ["solid-js", "vite-solid"],
97
+ ["svelte", "vite-svelte"],
98
+ ["vue", "vite-vue"],
99
+ ["preact", "vite-preact"],
100
+ ["react", "vite-react"],
101
+ ["lit", "vite-lit"]
102
+ ];
103
+ async function viteLibrary(reader) {
104
+ let manifest;
105
+ try {
106
+ manifest = JSON.parse(await reader.readFile("package.json"));
107
+ } catch {
108
+ return null;
109
+ }
110
+ const has = (name) => Boolean(manifest.dependencies?.[name] ?? manifest.devDependencies?.[name]);
111
+ return VITE_LIBRARIES.find(([dependency]) => has(dependency))?.[1] ?? null;
112
+ }
113
+ export {
114
+ STACK_SLUG_PATTERN,
115
+ detectStack,
116
+ stackForPreset
117
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naro-cli",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "naro": "./dist/index.js"
@@ -24,6 +24,7 @@
24
24
  "dependencies": {
25
25
  "@opennextjs/cloudflare": "1.20.2",
26
26
  "@supabase/supabase-js": "2.112.3",
27
+ "@vercel/frameworks": "3.34.0",
27
28
  "vinext": "1.0.0-beta.9",
28
29
  "wrangler": "4.124.0"
29
30
  },
@@ -32,10 +33,12 @@
32
33
  "tsx": "4.23.12",
33
34
  "typescript": "7.0.2",
34
35
  "vitest": "3.2.7",
36
+ "@naro/sdk": "0.1.0",
35
37
  "@next-deploy/build": "0.1.0",
38
+ "@next-deploy/config": "0.1.0",
39
+ "@next-deploy/data-core": "0.1.0",
36
40
  "@next-deploy/core": "0.1.0",
37
- "@next-deploy/sdk": "0.1.0",
38
- "@next-deploy/config": "0.1.0"
41
+ "@next-deploy/sdk": "0.1.0"
39
42
  },
40
43
  "scripts": {
41
44
  "build": "tsup && pnpm build:types",