@adaptive-js/create-adaptive-app 0.0.0-stage → 0.1.8
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/LICENSE +21 -0
- package/README.md +28 -2
- package/index.mjs +105 -0
- package/package.json +40 -4
- package/template/.env +1 -0
- package/template/_gitignore +5 -0
- package/template/index.html +13 -0
- package/template/package.json +20 -0
- package/template/public/styles.css +8 -0
- package/template/src/components/counter.tsx +46 -0
- package/template/src/pages/index.tsx +69 -0
- package/template/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antonio Johnathan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @adaptive-js/create-adaptive-app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create an [AdaptiveJS](https://github.com/SrJohnathan/adaptive-js) application with TypeScript, SSR, DOM-first hydration, and Tailwind 4.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @adaptive-js/create-adaptive-app
|
|
9
|
+
create-adaptive-app my-app
|
|
10
|
+
cd my-app
|
|
11
|
+
npm install
|
|
12
|
+
npm run dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Framework development
|
|
16
|
+
|
|
17
|
+
When running the scaffold from an AdaptiveJS checkout, `--local` points `@adaptive-js/web` and `@adaptive-js/ci` at the local packages. This option is for framework development; application users should omit it.
|
|
18
|
+
|
|
19
|
+
## What you get
|
|
20
|
+
|
|
21
|
+
- `src/pages` file-based routes
|
|
22
|
+
- an SSR-rendered page
|
|
23
|
+
- a `"hydrate"` island using signals and `memo`
|
|
24
|
+
- Tailwind 4 through `public/styles.css`
|
|
25
|
+
- `adaptive.config.ts` support from `@adaptive-js/ci`
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT
|
package/index.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const templateDir = path.join(__dirname, "template");
|
|
8
|
+
const monorepoRoot = path.resolve(__dirname, "..");
|
|
9
|
+
|
|
10
|
+
// Kept in sync with packages/web and packages/ci by scripts/check-packages.mjs.
|
|
11
|
+
const WEB_VERSION = "0.0.1";
|
|
12
|
+
const CI_VERSION = "0.0.1";
|
|
13
|
+
|
|
14
|
+
const args = process.argv.slice(2);
|
|
15
|
+
const projectName = args.find((arg) => !arg.startsWith("--"));
|
|
16
|
+
const localMode = args.includes("--local");
|
|
17
|
+
const unsupportedOption = args.find((arg) => arg.startsWith("--") && arg !== "--local");
|
|
18
|
+
|
|
19
|
+
if (!projectName || args.filter((arg) => !arg.startsWith("--")).length > 1) {
|
|
20
|
+
console.error("Usage: create-adaptive-app <project-name> [--local]");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (unsupportedOption) {
|
|
25
|
+
console.error(`Unsupported option: ${unsupportedOption}. This scaffold uses Tailwind 4.`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const targetDir = path.resolve(process.cwd(), projectName);
|
|
30
|
+
const appName = path.basename(targetDir);
|
|
31
|
+
|
|
32
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/i.test(appName)) {
|
|
33
|
+
console.error(`Invalid project name: ${appName}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
await fs.access(targetDir);
|
|
39
|
+
console.error(`Directory already exists: ${targetDir}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error?.code !== "ENOENT") throw error;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const replacements = createReplacements(targetDir);
|
|
46
|
+
await copyDir(templateDir, targetDir, replacements);
|
|
47
|
+
|
|
48
|
+
console.log(`Adaptive app created at ${targetDir}`);
|
|
49
|
+
console.log("");
|
|
50
|
+
console.log("Next steps:");
|
|
51
|
+
console.log(` cd ${projectName}`);
|
|
52
|
+
console.log(" npm install");
|
|
53
|
+
console.log(" npm run dev");
|
|
54
|
+
|
|
55
|
+
function createReplacements(targetDir) {
|
|
56
|
+
const replacements = {
|
|
57
|
+
__APP_NAME__: appName,
|
|
58
|
+
__WEB_DEP__: `^${WEB_VERSION}`,
|
|
59
|
+
__CI_DEP__: `^${CI_VERSION}`,
|
|
60
|
+
__ADAPTIVE_DEV__: "adaptive dev .",
|
|
61
|
+
__ADAPTIVE_BUILD__: "adaptive build .",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (!localMode) return replacements;
|
|
65
|
+
|
|
66
|
+
const relativeRoot = normalizePath(path.relative(targetDir, monorepoRoot));
|
|
67
|
+
const ciEntry = normalizePath(path.join(relativeRoot, "packages", "ci", "dist", "index.js"));
|
|
68
|
+
|
|
69
|
+
replacements.__WEB_DEP__ = `file:${normalizePath(path.join(relativeRoot, "packages", "web"))}`;
|
|
70
|
+
replacements.__CI_DEP__ = `file:${normalizePath(path.join(relativeRoot, "packages", "ci"))}`;
|
|
71
|
+
replacements.__ADAPTIVE_DEV__ = jsonStringContent(`node "${ciEntry}" dev .`);
|
|
72
|
+
replacements.__ADAPTIVE_BUILD__ = jsonStringContent(`node "${ciEntry}" build .`);
|
|
73
|
+
|
|
74
|
+
return replacements;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function jsonStringContent(value) {
|
|
78
|
+
return JSON.stringify(value).slice(1, -1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function normalizePath(value) {
|
|
82
|
+
return value.split(path.sep).join("/");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function copyDir(fromDir, toDir, replacements) {
|
|
86
|
+
await fs.mkdir(toDir, { recursive: true });
|
|
87
|
+
const entries = await fs.readdir(fromDir, { withFileTypes: true });
|
|
88
|
+
|
|
89
|
+
for (const entry of entries) {
|
|
90
|
+
const sourcePath = path.join(fromDir, entry.name);
|
|
91
|
+
const targetName = entry.name === "_gitignore" ? ".gitignore" : entry.name;
|
|
92
|
+
const targetPath = path.join(toDir, targetName);
|
|
93
|
+
|
|
94
|
+
if (entry.isDirectory()) {
|
|
95
|
+
await copyDir(sourcePath, targetPath, replacements);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let content = await fs.readFile(sourcePath, "utf8");
|
|
100
|
+
for (const [token, replacement] of Object.entries(replacements)) {
|
|
101
|
+
content = content.replaceAll(token, replacement);
|
|
102
|
+
}
|
|
103
|
+
await fs.writeFile(targetPath, content, "utf8");
|
|
104
|
+
}
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptive-js/create-adaptive-app",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"description": "Create an AdaptiveJS application with SSR, DOM-first hydration, and Tailwind 4.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"adaptive-js",
|
|
7
|
+
"create",
|
|
8
|
+
"scaffold",
|
|
9
|
+
"starter",
|
|
10
|
+
"template"
|
|
11
|
+
],
|
|
12
|
+
"author": "Antonio Johnathan",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/SrJohnathan/adaptive-js.git",
|
|
17
|
+
"directory": "create-adaptive-app"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/SrJohnathan/adaptive-js/tree/main/create-adaptive-app#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/SrJohnathan/adaptive-js/issues"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"bin": {
|
|
25
|
+
"create-adaptive-app": "index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.mjs",
|
|
29
|
+
"template"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "node --check index.mjs",
|
|
33
|
+
"typecheck": "node --check index.mjs",
|
|
34
|
+
"prepublishOnly": "node --check index.mjs"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20.0.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/template/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ADAPTIVE_ENABLED_CLIENT=1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="pt-BR">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<!--adaptive-head-->
|
|
7
|
+
<link rel="stylesheet" href="/styles.css" />
|
|
8
|
+
<!--hydration-script-->
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"><!--app-html--></div>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "__ADAPTIVE_DEV__",
|
|
7
|
+
"build": "__ADAPTIVE_BUILD__",
|
|
8
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@adaptive-js/ci": "__CI_DEP__",
|
|
12
|
+
"@adaptive-js/web": "__WEB_DEP__"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@tailwindcss/postcss": "^4.1.7",
|
|
16
|
+
"postcss": "^8.5.6",
|
|
17
|
+
"tailwindcss": "^4.1.7",
|
|
18
|
+
"typescript": "^6.0.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"hydrate";
|
|
2
|
+
|
|
3
|
+
import { memo, signal } from "@adaptive-js/web";
|
|
4
|
+
|
|
5
|
+
export default function Counter() {
|
|
6
|
+
const [count, setCount] = signal(0);
|
|
7
|
+
const double = memo(() => count() * 2);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<section className="rounded-3xl border border-emerald-950/10 bg-white p-6 shadow-xl shadow-emerald-950/5 sm:p-8">
|
|
11
|
+
<div className="flex items-center justify-between gap-4">
|
|
12
|
+
<div>
|
|
13
|
+
<p className="text-xs font-bold uppercase tracking-[0.18em] text-emerald-700">Ilha hidratada</p>
|
|
14
|
+
<h2 className="mt-2 text-2xl font-bold tracking-tight">Contador reativo</h2>
|
|
15
|
+
</div>
|
|
16
|
+
<span className="rounded-full bg-emerald-950 px-3 py-1 font-mono text-xs text-lime-200">"hydrate"</span>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div className="mt-8 flex items-center justify-center gap-5">
|
|
20
|
+
<button
|
|
21
|
+
type="button"
|
|
22
|
+
onClick={() => setCount((value) => value - 1)}
|
|
23
|
+
className="h-12 w-12 rounded-2xl border border-emerald-950/10 text-2xl font-bold transition hover:bg-emerald-50"
|
|
24
|
+
aria-label="Diminuir"
|
|
25
|
+
>
|
|
26
|
+
−
|
|
27
|
+
</button>
|
|
28
|
+
<strong className="min-w-20 text-center font-mono text-5xl tracking-tight text-emerald-950" aria-live="polite">
|
|
29
|
+
{() => count()}
|
|
30
|
+
</strong>
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
onClick={() => setCount((value) => value + 1)}
|
|
34
|
+
className="h-12 w-12 rounded-2xl bg-emerald-950 text-2xl font-bold text-lime-200 transition hover:bg-emerald-800"
|
|
35
|
+
aria-label="Aumentar"
|
|
36
|
+
>
|
|
37
|
+
+
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<p className="mt-6 text-center text-sm text-slate-600">
|
|
42
|
+
O dobro do valor é <span className="font-mono font-bold text-emerald-700">{() => double()}</span>.
|
|
43
|
+
</p>
|
|
44
|
+
</section>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import Counter from "../components/counter";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Metadados de compartilhamento da home.
|
|
5
|
+
* O AdaptiveJS injeta estas tags no <head> (via <!--adaptive-head-->):
|
|
6
|
+
* title, description, og:* e twitter:*.
|
|
7
|
+
* Para usar imagem, coloque o arquivo em public/og-image.png e adicione
|
|
8
|
+
* `image: "/og-image.png"` (ou a URL absoluta) nos dois objetos abaixo.
|
|
9
|
+
*/
|
|
10
|
+
export const metadata = {
|
|
11
|
+
title: "__APP_NAME__ · AdaptiveJS",
|
|
12
|
+
description:
|
|
13
|
+
"Aplicação AdaptiveJS com SSR, hidratação DOM-first, reatividade granular e Tailwind 4.",
|
|
14
|
+
siteName: "__APP_NAME__",
|
|
15
|
+
locale: "pt_BR",
|
|
16
|
+
type: "website",
|
|
17
|
+
openGraph: {
|
|
18
|
+
title: "__APP_NAME__ · AdaptiveJS",
|
|
19
|
+
description:
|
|
20
|
+
"Aplicação AdaptiveJS com SSR, hidratação DOM-first, reatividade granular e Tailwind 4.",
|
|
21
|
+
siteName: "__APP_NAME__",
|
|
22
|
+
locale: "pt_BR",
|
|
23
|
+
type: "website",
|
|
24
|
+
},
|
|
25
|
+
twitter: {
|
|
26
|
+
card: "summary_large_image",
|
|
27
|
+
title: "__APP_NAME__ · AdaptiveJS",
|
|
28
|
+
description:
|
|
29
|
+
"Aplicação AdaptiveJS com SSR, hidratação DOM-first, reatividade granular e Tailwind 4.",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default function HomePage() {
|
|
34
|
+
return (
|
|
35
|
+
<main className="min-h-screen bg-[#f6f7f2] px-5 py-10 text-[#17231d] sm:px-8 sm:py-16">
|
|
36
|
+
<div className="mx-auto max-w-5xl">
|
|
37
|
+
<header className="flex flex-wrap items-center justify-between gap-4">
|
|
38
|
+
<a href="/" className="text-lg font-bold tracking-tight text-emerald-950">__APP_NAME__</a>
|
|
39
|
+
<span className="rounded-full border border-emerald-950/10 bg-white px-3 py-1 text-xs font-semibold text-emerald-700">
|
|
40
|
+
AdaptiveJS + Tailwind 4
|
|
41
|
+
</span>
|
|
42
|
+
</header>
|
|
43
|
+
|
|
44
|
+
<section className="mt-12 grid items-center gap-10 lg:grid-cols-[1.15fr_0.85fr]">
|
|
45
|
+
<div>
|
|
46
|
+
<p className="text-xs font-bold uppercase tracking-[0.2em] text-emerald-700">SSR · DOM-first · TypeScript</p>
|
|
47
|
+
<h1 className="mt-5 max-w-3xl text-5xl font-bold leading-[0.98] tracking-[-0.055em] text-emerald-950 sm:text-6xl">
|
|
48
|
+
Seu projeto já começa renderizado no servidor.
|
|
49
|
+
</h1>
|
|
50
|
+
<p className="mt-6 max-w-2xl text-lg leading-8 text-slate-600">
|
|
51
|
+
Esta página veio do SSR. O contador ao lado é uma ilha <code className="font-mono text-emerald-700">"hydrate"</code> que conecta eventos e sinais ao DOM existente.
|
|
52
|
+
</p>
|
|
53
|
+
<div className="mt-8 flex flex-wrap gap-3 text-xs font-semibold text-slate-600">
|
|
54
|
+
<span className="rounded-xl border border-emerald-950/10 bg-white px-3 py-2">src/pages define as rotas</span>
|
|
55
|
+
<span className="rounded-xl border border-emerald-950/10 bg-white px-3 py-2">public/styles.css carrega o Tailwind</span>
|
|
56
|
+
<span className="rounded-xl border border-emerald-950/10 bg-white px-3 py-2">signal atualiza sem VDOM global</span>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<Counter />
|
|
61
|
+
</section>
|
|
62
|
+
|
|
63
|
+
<footer className="mt-14 border-t border-emerald-950/10 pt-6 text-sm text-slate-500">
|
|
64
|
+
Edite <code className="font-mono text-emerald-700">src/pages/index.tsx</code> e execute <code className="font-mono text-emerald-700">npm run dev</code>.
|
|
65
|
+
</footer>
|
|
66
|
+
</div>
|
|
67
|
+
</main>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"jsxImportSource": "@adaptive-js/web",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"noEmit": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|