@namostack/cli 0.0.1 → 0.1.0-rc.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/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@namostack/cli",
3
- "version": "0.0.1",
4
- "description": "Not released yet: see https://docs.namostack.com",
5
- "license": "MIT"
6
- }
3
+ "version": "0.1.0-rc.1",
4
+ "description": "Create, live test and publish namostack plugins.",
5
+ "license": "MIT",
6
+ "homepage": "https://docs.namostack.com",
7
+ "keywords": [
8
+ "namostack",
9
+ "plugin",
10
+ "cli"
11
+ ],
12
+ "type": "module",
13
+ "bin": {
14
+ "namostack": "./dist/index.mjs"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "templates",
19
+ "!templates/*/node_modules",
20
+ "!templates/*/.turbo",
21
+ "!templates/*/dist"
22
+ ],
23
+ "engines": {
24
+ "node": "^20.19.0 || >=22.12.0"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "dependencies": {
30
+ "@clack/prompts": "^1.8.1",
31
+ "citty": "^0.2.2",
32
+ "picocolors": "^1.1.1",
33
+ "semver": "^7.8.5",
34
+ "tar": "^7.5.22",
35
+ "vite": "^8.3.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^24.13.3",
39
+ "@types/semver": "^7.8.0",
40
+ "tsdown": "^0.23.1",
41
+ "typescript": "~6.0.2",
42
+ "@namostack/config": "0.0.0",
43
+ "@namostack/tsconfig": "0.0.0",
44
+ "@namostack/api-client": "0.0.0",
45
+ "@namostack/types": "0.0.0"
46
+ },
47
+ "scripts": {
48
+ "build": "tsdown",
49
+ "lint": "oxlint",
50
+ "typecheck": "tsc -b"
51
+ }
52
+ }
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ dist
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{name}}</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "template-react",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "tsc"
8
+ },
9
+ "dependencies": {
10
+ "@fontsource-variable/inter": "^5.3.0",
11
+ "@fontsource-variable/source-serif-4": "^5.3.1",
12
+ "@juliensouki/seedui": "0.0.4",
13
+ "@namostack/plugin-sdk": "workspace:*",
14
+ "react": "^19.2.8",
15
+ "react-dom": "^19.2.8",
16
+ "styled-components": "^6.1.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^19.2.18",
20
+ "@types/react-dom": "^19.2.7",
21
+ "@vitejs/plugin-react": "^6.1.1",
22
+ "typescript": "~6.0.2",
23
+ "vite": "^8.3.0"
24
+ }
25
+ }
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#4f46e5" />
3
+ <path d="M22 16h13a11 11 0 0 1 0 22h-6v10h-7zm7 6v10h6a5 5 0 0 0 0-10z" fill="#fff" fill-rule="evenodd" />
4
+ </svg>
@@ -0,0 +1,10 @@
1
+ import { Text } from '@juliensouki/seedui';
2
+ import { useNamostack } from './useNamostack';
3
+
4
+ export function App() {
5
+ const { context } = useNamostack();
6
+
7
+ return (
8
+ <Text variant="h3">Welcome to your namostack plugin {context.name}</Text>
9
+ );
10
+ }
@@ -0,0 +1,32 @@
1
+ import { ThemeProvider } from '@juliensouki/seedui';
2
+ import type { Namostack } from '@namostack/plugin-sdk';
3
+ import { useEffect, useState, type ReactNode } from 'react';
4
+ import { NamostackContext } from './useNamostack';
5
+
6
+ interface NamostackProviderProps {
7
+ namostack: Namostack;
8
+ children: ReactNode;
9
+ }
10
+
11
+ /** Shares the connection with every component, and follows the app's theme. */
12
+ export function NamostackProvider({
13
+ namostack,
14
+ children,
15
+ }: NamostackProviderProps) {
16
+ const [mode, setMode] = useState(namostack.context.theme.mode);
17
+
18
+ useEffect(
19
+ () => namostack.onThemeChange((theme) => setMode(theme.mode)),
20
+ [namostack],
21
+ );
22
+
23
+ useEffect(() => {
24
+ document.documentElement.style.colorScheme = mode;
25
+ }, [mode]);
26
+
27
+ return (
28
+ <NamostackContext.Provider value={namostack}>
29
+ <ThemeProvider mode={mode}>{children}</ThemeProvider>
30
+ </NamostackContext.Provider>
31
+ );
32
+ }
@@ -0,0 +1,20 @@
1
+ import { connect } from '@namostack/plugin-sdk';
2
+ import { StrictMode } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { App } from './App';
5
+ import { NamostackProvider } from './NamostackProvider';
6
+
7
+ // seedui's fonts, as in the namostack app.
8
+ import '@fontsource-variable/inter';
9
+ import '@fontsource-variable/source-serif-4';
10
+
11
+ // Plugins only run inside the namostack app: anywhere else, this throws.
12
+ const namostack = await connect();
13
+
14
+ createRoot(document.getElementById('root')!).render(
15
+ <StrictMode>
16
+ <NamostackProvider namostack={namostack}>
17
+ <App />
18
+ </NamostackProvider>
19
+ </StrictMode>,
20
+ );
@@ -0,0 +1,16 @@
1
+ import type { Namostack } from '@namostack/plugin-sdk';
2
+ import { createContext, useContext } from 'react';
3
+
4
+ /** Provided by `NamostackProvider`. */
5
+ export const NamostackContext = createContext<Namostack | undefined>(undefined);
6
+
7
+ /** The data, user and UI methods of the namostack app. */
8
+ export function useNamostack(): Namostack {
9
+ const namostack = useContext(NamostackContext);
10
+
11
+ if (!namostack) {
12
+ throw new Error('useNamostack is only usable inside NamostackProvider.');
13
+ }
14
+
15
+ return namostack;
16
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2023",
4
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
5
+ "module": "esnext",
6
+ "moduleResolution": "bundler",
7
+ "allowImportingTsExtensions": true,
8
+ "jsx": "react-jsx",
9
+ "types": ["vite/client"],
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "noEmit": true
13
+ },
14
+ "include": ["src", "vite.config.ts"]
15
+ }
@@ -0,0 +1,7 @@
1
+ import { namostackPlugin } from '@namostack/plugin-sdk/vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import { defineConfig } from 'vite';
4
+
5
+ export default defineConfig({
6
+ plugins: [react(), namostackPlugin()],
7
+ });
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ dist
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{name}}</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "template-vanilla",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "tsc"
8
+ },
9
+ "dependencies": {
10
+ "@namostack/plugin-sdk": "workspace:*"
11
+ },
12
+ "devDependencies": {
13
+ "typescript": "~6.0.2",
14
+ "vite": "^8.3.0"
15
+ }
16
+ }
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="14" fill="#4f46e5" />
3
+ <path d="M22 16h13a11 11 0 0 1 0 22h-6v10h-7zm7 6v10h6a5 5 0 0 0 0-10z" fill="#fff" fill-rule="evenodd" />
4
+ </svg>
@@ -0,0 +1,17 @@
1
+ import { connect, type PluginTheme } from '@namostack/plugin-sdk';
2
+
3
+ // Plugins only run inside the namostack app: anywhere else, this throws.
4
+ const namostack = await connect();
5
+
6
+ /** Follows the app's light or dark mode; style against `[data-mode="dark"]`. */
7
+ function applyTheme({ mode }: PluginTheme) {
8
+ document.documentElement.dataset.mode = mode;
9
+ document.documentElement.style.colorScheme = mode;
10
+ }
11
+
12
+ applyTheme(namostack.context.theme);
13
+ namostack.onThemeChange(applyTheme);
14
+
15
+ // textContent, not innerHTML: the name is the developer's own text.
16
+ document.getElementById('root')!.textContent =
17
+ `Welcome to your namostack plugin ${namostack.context.name}`;
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2023",
4
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
5
+ "module": "esnext",
6
+ "moduleResolution": "bundler",
7
+ "allowImportingTsExtensions": true,
8
+ "types": ["vite/client"],
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true
12
+ },
13
+ "include": ["src", "vite.config.ts"]
14
+ }
@@ -0,0 +1,6 @@
1
+ import { namostackPlugin } from '@namostack/plugin-sdk/vite';
2
+ import { defineConfig } from 'vite';
3
+
4
+ export default defineConfig({
5
+ plugins: [namostackPlugin()],
6
+ });