@springmicro/cli 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -26,7 +26,7 @@ $ npm install -g @springmicro/cli
26
26
  $ springmicro COMMAND
27
27
  running command...
28
28
  $ springmicro (--version)
29
- @springmicro/cli/0.1.7 win32-x64 node-v18.17.1
29
+ @springmicro/cli/0.1.9 win32-x64 node-v18.17.1
30
30
  $ springmicro --help [COMMAND]
31
31
  USAGE
32
32
  $ springmicro COMMAND
@@ -51,6 +51,7 @@ USAGE
51
51
  # Commands
52
52
 
53
53
  <!-- commands -->
54
+ * [`springmicro add auth`](#springmicro-add-auth)
54
55
  * [`springmicro help [COMMAND]`](#springmicro-help-command)
55
56
  * [`springmicro init PROJECTTYPE`](#springmicro-init-projecttype)
56
57
  * [`springmicro init astro`](#springmicro-init-astro)
@@ -65,6 +66,23 @@ USAGE
65
66
  * [`springmicro plugins unlink [PLUGIN]`](#springmicro-plugins-unlink-plugin)
66
67
  * [`springmicro plugins update`](#springmicro-plugins-update)
67
68
 
69
+ ## `springmicro add auth`
70
+
71
+ describe the command here
72
+
73
+ ```
74
+ USAGE
75
+ $ springmicro add auth
76
+
77
+ DESCRIPTION
78
+ describe the command here
79
+
80
+ EXAMPLES
81
+ $ springmicro add auth
82
+ ```
83
+
84
+ _See code: [src/commands/add/auth.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.9/src/commands/add/auth.ts)_
85
+
68
86
  ## `springmicro help [COMMAND]`
69
87
 
70
88
  Display help for springmicro.
@@ -106,7 +124,7 @@ EXAMPLES
106
124
  $ springmicro init astro -n example
107
125
  ```
108
126
 
109
- _See code: [src/commands/init/index.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.7/src/commands/init/index.ts)_
127
+ _See code: [src/commands/init/index.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.9/src/commands/init/index.ts)_
110
128
 
111
129
  ## `springmicro init astro`
112
130
 
@@ -126,7 +144,7 @@ EXAMPLES
126
144
  $ springmicro init astro -n <project-name>
127
145
  ```
128
146
 
129
- _See code: [src/commands/init/astro.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.7/src/commands/init/astro.ts)_
147
+ _See code: [src/commands/init/astro.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.9/src/commands/init/astro.ts)_
130
148
 
131
149
  ## `springmicro plugins`
132
150
 
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Auth extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ writeAuthConfig(): void;
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,28 @@
1
+ import { Command } from '@oclif/core';
2
+ import { checkUnixShellAndSpawn } from '../../utils/shell.js';
3
+ import path from 'node:path';
4
+ import { authConfigTs } from '../../data/astro/index.js';
5
+ import fs from 'node:fs';
6
+ import chalk from 'chalk';
7
+ export default class Auth extends Command {
8
+ // static override args = {
9
+ // file: Args.string({description: 'file to read'}),
10
+ // }
11
+ static description = 'describe the command here';
12
+ static examples = ['<%= config.bin %> <%= command.id %>'];
13
+ // static override flags = {
14
+ // // flag with no value (-f, --force)
15
+ // force: Flags.boolean({char: 'f'}),
16
+ // // flag with a value (-n, --name=VALUE)
17
+ // name: Flags.string({char: 'n', description: 'name to print'}),
18
+ // }
19
+ writeAuthConfig() {
20
+ fs.writeFileSync('auth.config.ts', authConfigTs);
21
+ this.log('');
22
+ this.log(chalk.bgCyan.black('FINISHED!'));
23
+ }
24
+ async run() {
25
+ // const {args, flags} = await this.parse(Auth)
26
+ await checkUnixShellAndSpawn('sh', [path.posix.join(this.config.root, 'dist', 'scripts', 'auth.sh')], path.join(this.config.root, 'dist', 'scripts', 'auth.bat'), [], () => this.writeAuthConfig());
27
+ }
28
+ }
@@ -5,6 +5,7 @@ import { tailwindConfigMjs, globalsCSS, libUtils, componentsJSON } from '../../d
5
5
  import chalk from 'chalk';
6
6
  import { logStep } from '../../log/index.js';
7
7
  import { checkUnixShellAndSpawn } from '../../utils/shell.js';
8
+ import { replaceHeadContents } from '../../data/astro/replace.js';
8
9
  export default class Astro extends Command {
9
10
  static step = 1;
10
11
  static totalSteps = 2;
@@ -38,6 +39,7 @@ export default class Astro extends Command {
38
39
  const libUtilsPath = path.join(name, 'src', 'lib');
39
40
  const libUtilsFilePath = path.join(libUtilsPath, 'utils.ts');
40
41
  const publicFontsDirPath = path.join(name, 'public', 'fonts');
42
+ const baseHeadPath = path.join(name, 'src', 'components', 'BaseHead.astro');
41
43
  const tsConfig = JSON.parse(fs.readFileSync(tsConfigFilePath).toString());
42
44
  // see https://ui.shadcn.com/docs/installation/manual
43
45
  // extracted 6/6/2024
@@ -45,7 +47,7 @@ export default class Astro extends Command {
45
47
  ...tsConfig['compilerOptions'],
46
48
  baseUrl: '.',
47
49
  paths: {
48
- '@/*': ['./*'],
50
+ '@/*': ['./src/*'],
49
51
  },
50
52
  };
51
53
  this.log('write to ' + chalk.cyan(tsConfigFilePath));
@@ -61,6 +63,9 @@ export default class Astro extends Command {
61
63
  fs.mkdirSync(libUtilsPath, { recursive: true });
62
64
  }
63
65
  fs.writeFileSync(libUtilsFilePath, libUtils);
66
+ // file manip
67
+ this.log('replace contents of ' + chalk.greenBright(libUtilsFilePath));
68
+ replaceHeadContents(baseHeadPath);
64
69
  // remove any extra files
65
70
  this.log('remove unused ' + chalk.red(publicFontsDirPath));
66
71
  fs.rmSync(publicFontsDirPath, {
@@ -1,8 +1,9 @@
1
- export declare const tailwindConfigMjs = "const { fontFamily } = require(\"tailwindcss/defaultTheme\")\n\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n darkMode: [\"class\"],\n content: [\"./src/**/*.{ts,tsx,astro}\"],\n theme: {\n container: {\n center: true,\n padding: \"2rem\",\n screens: {\n \"2xl\": \"1400px\",\n },\n },\n extend: {\n colors: {\n border: \"hsl(var(--border))\",\n input: \"hsl(var(--input))\",\n ring: \"hsl(var(--ring))\",\n background: \"hsl(var(--background))\",\n foreground: \"hsl(var(--foreground))\",\n primary: {\n DEFAULT: \"hsl(var(--primary))\",\n foreground: \"hsl(var(--primary-foreground))\",\n },\n secondary: {\n DEFAULT: \"hsl(var(--secondary))\",\n foreground: \"hsl(var(--secondary-foreground))\",\n },\n destructive: {\n DEFAULT: \"hsl(var(--destructive))\",\n foreground: \"hsl(var(--destructive-foreground))\",\n },\n muted: {\n DEFAULT: \"hsl(var(--muted))\",\n foreground: \"hsl(var(--muted-foreground))\",\n },\n accent: {\n DEFAULT: \"hsl(var(--accent))\",\n foreground: \"hsl(var(--accent-foreground))\",\n },\n popover: {\n DEFAULT: \"hsl(var(--popover))\",\n foreground: \"hsl(var(--popover-foreground))\",\n },\n card: {\n DEFAULT: \"hsl(var(--card))\",\n foreground: \"hsl(var(--card-foreground))\",\n },\n },\n borderRadius: {\n lg: `var(--radius)`,\n md: `calc(var(--radius) - 2px)`,\n sm: \"calc(var(--radius) - 4px)\",\n },\n fontFamily: {\n sans: [\"var(--font-sans)\", ...fontFamily.sans],\n },\n keyframes: {\n \"accordion-down\": {\n from: { height: \"0\" },\n to: { height: \"var(--radix-accordion-content-height)\" },\n },\n \"accordion-up\": {\n from: { height: \"var(--radix-accordion-content-height)\" },\n to: { height: \"0\" },\n },\n },\n animation: {\n \"accordion-down\": \"accordion-down 0.2s ease-out\",\n \"accordion-up\": \"accordion-up 0.2s ease-out\",\n },\n },\n },\n plugins: [require(\"tailwindcss-animate\")],\n}";
2
- export declare const globalsCSS = "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n@layer base {\n :root {\n /* default font added */\n --font-sans: ui-sans-serif;\n\n --background: 0 0% 100%;\n --foreground: 222.2 47.4% 11.2%;\n\n --muted: 210 40% 96.1%;\n --muted-foreground: 215.4 16.3% 46.9%;\n\n --popover: 0 0% 100%;\n --popover-foreground: 222.2 47.4% 11.2%;\n\n --border: 214.3 31.8% 91.4%;\n --input: 214.3 31.8% 91.4%;\n\n --card: 0 0% 100%;\n --card-foreground: 222.2 47.4% 11.2%;\n\n --primary: 222.2 47.4% 11.2%;\n --primary-foreground: 210 40% 98%;\n\n --secondary: 210 40% 96.1%;\n --secondary-foreground: 222.2 47.4% 11.2%;\n\n --accent: 210 40% 96.1%;\n --accent-foreground: 222.2 47.4% 11.2%;\n\n --destructive: 0 100% 50%;\n --destructive-foreground: 210 40% 98%;\n\n --ring: 215 20.2% 65.1%;\n\n --radius: 0.5rem;\n }\n\n .dark {\n --background: 224 71% 4%;\n --foreground: 213 31% 91%;\n\n --muted: 223 47% 11%;\n --muted-foreground: 215.4 16.3% 56.9%;\n\n --accent: 216 34% 17%;\n --accent-foreground: 210 40% 98%;\n\n --popover: 224 71% 4%;\n --popover-foreground: 215 20.2% 65.1%;\n\n --border: 216 34% 17%;\n --input: 216 34% 17%;\n\n --card: 224 71% 4%;\n --card-foreground: 213 31% 91%;\n\n --primary: 210 40% 98%;\n --primary-foreground: 222.2 47.4% 1.2%;\n\n --secondary: 222.2 47.4% 11.2%;\n --secondary-foreground: 210 40% 98%;\n\n --destructive: 0 63% 31%;\n --destructive-foreground: 210 40% 98%;\n\n --ring: 216 34% 17%;\n\n --radius: 0.5rem;\n }\n}\n\n@layer base {\n * {\n @apply border-border;\n }\n body {\n @apply bg-background text-foreground;\n font-feature-settings: \"rlig\" 1, \"calt\" 1;\n }\n /* custom from blog astro template */\n main {\n width: 720px;\n max-width: calc(100% - 2em);\n margin: auto;\n padding: 3em 1em;\n }\n .prose p {\n\t margin-bottom: 2em;\n }\n}\n";
1
+ export declare const tailwindConfigMjs = "const { fontFamily } = require(\"tailwindcss/defaultTheme\")\n\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n darkMode: [\"class\"],\n content: [\"./src/**/*.{ts,tsx,astro}\"],\n theme: {\n container: {\n center: true,\n padding: \"2rem\",\n screens: {\n \"2xl\": \"1400px\",\n },\n },\n extend: {\n colors: {\n border: \"hsl(var(--border))\",\n input: \"hsl(var(--input))\",\n ring: \"hsl(var(--ring))\",\n background: \"hsl(var(--background))\",\n foreground: \"hsl(var(--foreground))\",\n primary: {\n DEFAULT: \"hsl(var(--primary))\",\n foreground: \"hsl(var(--primary-foreground))\",\n },\n secondary: {\n DEFAULT: \"hsl(var(--secondary))\",\n foreground: \"hsl(var(--secondary-foreground))\",\n },\n destructive: {\n DEFAULT: \"hsl(var(--destructive))\",\n foreground: \"hsl(var(--destructive-foreground))\",\n },\n muted: {\n DEFAULT: \"hsl(var(--muted))\",\n foreground: \"hsl(var(--muted-foreground))\",\n },\n accent: {\n DEFAULT: \"hsl(var(--accent))\",\n foreground: \"hsl(var(--accent-foreground))\",\n },\n popover: {\n DEFAULT: \"hsl(var(--popover))\",\n foreground: \"hsl(var(--popover-foreground))\",\n },\n card: {\n DEFAULT: \"hsl(var(--card))\",\n foreground: \"hsl(var(--card-foreground))\",\n },\n },\n borderRadius: {\n lg: `var(--radius)`,\n md: `calc(var(--radius) - 2px)`,\n sm: \"calc(var(--radius) - 4px)\",\n },\n fontFamily: {\n sans: [\"var(--font-sans)\", ...fontFamily.sans],\n },\n keyframes: {\n \"accordion-down\": {\n from: { height: \"0\" },\n to: { height: \"var(--radix-accordion-content-height)\" },\n },\n \"accordion-up\": {\n from: { height: \"var(--radix-accordion-content-height)\" },\n to: { height: \"0\" },\n },\n },\n animation: {\n \"accordion-down\": \"accordion-down 0.2s ease-out\",\n \"accordion-up\": \"accordion-up 0.2s ease-out\",\n },\n },\n },\n plugins: [require(\"@tailwindcss/typography\"), require(\"tailwindcss-animate\")],\n}";
2
+ export declare const globalsCSS = "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n@layer base {\n :root {\n /* default font added */\n --font-sans: ui-sans-serif;\n\n --background: 0 0% 100%;\n --foreground: 222.2 47.4% 11.2%;\n\n --muted: 210 40% 96.1%;\n --muted-foreground: 215.4 16.3% 46.9%;\n\n --popover: 0 0% 100%;\n --popover-foreground: 222.2 47.4% 11.2%;\n\n --border: 214.3 31.8% 91.4%;\n --input: 214.3 31.8% 91.4%;\n\n --card: 0 0% 100%;\n --card-foreground: 222.2 47.4% 11.2%;\n\n --primary: 222.2 47.4% 11.2%;\n --primary-foreground: 210 40% 98%;\n\n --secondary: 210 40% 96.1%;\n --secondary-foreground: 222.2 47.4% 11.2%;\n\n --accent: 210 40% 96.1%;\n --accent-foreground: 222.2 47.4% 11.2%;\n\n --destructive: 0 100% 50%;\n --destructive-foreground: 210 40% 98%;\n\n --ring: 215 20.2% 65.1%;\n\n --radius: 0.5rem;\n }\n\n .dark {\n --background: 224 71% 4%;\n --foreground: 213 31% 91%;\n\n --muted: 223 47% 11%;\n --muted-foreground: 215.4 16.3% 56.9%;\n\n --accent: 216 34% 17%;\n --accent-foreground: 210 40% 98%;\n\n --popover: 224 71% 4%;\n --popover-foreground: 215 20.2% 65.1%;\n\n --border: 216 34% 17%;\n --input: 216 34% 17%;\n\n --card: 224 71% 4%;\n --card-foreground: 213 31% 91%;\n\n --primary: 210 40% 98%;\n --primary-foreground: 222.2 47.4% 1.2%;\n\n --secondary: 222.2 47.4% 11.2%;\n --secondary-foreground: 210 40% 98%;\n\n --destructive: 0 63% 31%;\n --destructive-foreground: 210 40% 98%;\n\n --ring: 216 34% 17%;\n\n --radius: 0.5rem;\n }\n}\n\n@layer base {\n * {\n @apply border-border;\n }\n body {\n @apply bg-background text-foreground;\n font-feature-settings: \"rlig\" 1, \"calt\" 1;\n }\n /* custom from blog astro template */\n main {\n width: 720px;\n max-width: calc(100% - 2em);\n margin: auto;\n padding: 3em 1em;\n }\n}\n";
3
3
  export declare const libUtils = "import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n";
4
4
  /**
5
5
  * from https://ui.shadcn.com/docs/components-json
6
6
  * only change is globals.css => global.css
7
7
  */
8
8
  export declare const componentsJSON = "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.mjs\",\n \"css\": \"./src/styles/global.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\"\n }\n}";
9
+ export declare const authConfigTs = "import { getAuthConfig } from \"@springmicro/auth\";\n\nexport default getAuthConfig({\n casdoorEndpoint: import.meta.env.PUBLIC_CASDOOR_ENDPOINT,\n clientId: import.meta.env.PUBLIC_CASDOOR_CLIENT_ID,\n clientSecret: import.meta.env.CASDOOR_CLIENT_SECRET,\n});";
@@ -75,7 +75,7 @@ module.exports = {
75
75
  },
76
76
  },
77
77
  },
78
- plugins: [require("tailwindcss-animate")],
78
+ plugins: [require("@tailwindcss/typography"), require("tailwindcss-animate")],
79
79
  }`;
80
80
  export const globalsCSS = `@tailwind base;
81
81
  @tailwind components;
@@ -167,9 +167,6 @@ export const globalsCSS = `@tailwind base;
167
167
  margin: auto;
168
168
  padding: 3em 1em;
169
169
  }
170
- .prose p {
171
- margin-bottom: 2em;
172
- }
173
170
  }
174
171
  `;
175
172
  export const libUtils = `import { clsx, type ClassValue } from "clsx"
@@ -200,3 +197,10 @@ export const componentsJSON = `{
200
197
  "utils": "@/lib/utils"
201
198
  }
202
199
  }`;
200
+ export const authConfigTs = `import { getAuthConfig } from "@springmicro/auth";
201
+
202
+ export default getAuthConfig({
203
+ casdoorEndpoint: import.meta.env.PUBLIC_CASDOOR_ENDPOINT,
204
+ clientId: import.meta.env.PUBLIC_CASDOOR_CLIENT_ID,
205
+ clientSecret: import.meta.env.CASDOOR_CLIENT_SECRET,
206
+ });`;
@@ -0,0 +1,2 @@
1
+ /** Replace any head contents that we don't need like font preloads */
2
+ export declare function replaceHeadContents(filePath: string): void;
@@ -0,0 +1,8 @@
1
+ import fs from 'node:fs';
2
+ /** Replace any head contents that we don't need like font preloads */
3
+ export function replaceHeadContents(filePath) {
4
+ const data = fs.readFileSync(filePath).toString();
5
+ const regex = /<link rel="preload" href="\/fonts\/atkinson-.*?\.woff" as="font" type="font\/woff" crossorigin \/>/g;
6
+ const result = data.replace(regex, '');
7
+ fs.writeFileSync(filePath, result);
8
+ }
@@ -23,8 +23,12 @@ if errorlevel 1 exit /b %errorlevel%
23
23
  pnpx astro add tailwind -y
24
24
  if errorlevel 1 exit /b %errorlevel%
25
25
 
26
- :: Install additional packages for shadcn-ui
27
- pnpm install tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react
26
+ :: Install additional packages for shadcn-ui + icon libraries
27
+ pnpm install tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react react-icons
28
+ if errorlevel 1 exit /b %errorlevel%
29
+
30
+ :: Install dev packages
31
+ pnpm install -D @tailwindcss/typography
28
32
  if errorlevel 1 exit /b %errorlevel%
29
33
 
30
34
  endlocal
@@ -5,4 +5,5 @@ pnpx astro add react -y
5
5
  pnpx astro add tailwind -y
6
6
  # shadcn-ui
7
7
  # https://ui.shadcn.com/docs/installation/manual
8
- pnpm install tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react
8
+ pnpm install tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react react-icons
9
+ pnpm install -D @tailwindcss/typography
@@ -0,0 +1,5 @@
1
+ @echo off
2
+
3
+ REM Use PowerShell to simulate yes command and pipe to pnpm
4
+ powershell -Command "while ($true) { Write-Output 'y' }" | pnpm run astro add auth-astro
5
+ pnpm add @springmicro/auth
@@ -0,0 +1,4 @@
1
+ # https://github.com/nowaythatworked/auth-astro?tab=readme-ov-file#installation
2
+ # https://unix.stackexchange.com/a/512368
3
+ yes | pnpm run astro add auth-astro
4
+ pnpm add @springmicro/auth
@@ -1,5 +1,29 @@
1
1
  {
2
2
  "commands": {
3
+ "add:auth": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "describe the command here",
7
+ "examples": [
8
+ "<%= config.bin %> <%= command.id %>"
9
+ ],
10
+ "flags": {},
11
+ "hasDynamicHelp": false,
12
+ "hiddenAliases": [],
13
+ "id": "add:auth",
14
+ "pluginAlias": "@springmicro/cli",
15
+ "pluginName": "@springmicro/cli",
16
+ "pluginType": "core",
17
+ "strict": true,
18
+ "enableJsonFlag": false,
19
+ "isESM": true,
20
+ "relativePath": [
21
+ "dist",
22
+ "commands",
23
+ "add",
24
+ "auth.js"
25
+ ]
26
+ },
3
27
  "init:astro": {
4
28
  "aliases": [],
5
29
  "args": {},
@@ -77,5 +101,5 @@
77
101
  ]
78
102
  }
79
103
  },
80
- "version": "0.1.7"
104
+ "version": "0.1.9"
81
105
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@springmicro/cli",
3
3
  "description": "A new CLI generated with oclif",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "author": "David Buckley",
6
6
  "private": false,
7
7
  "publishConfig": {
@@ -76,5 +76,5 @@
76
76
  "version": "oclif readme && git add README.md"
77
77
  },
78
78
  "types": "dist/index.d.ts",
79
- "gitHead": "aa6817163ba8ebcd819ad72277c321c6cc30d269"
79
+ "gitHead": "68c03879e19bc3f7381bfad0663c14f85c32514b"
80
80
  }