@styleframe/cli 1.0.2 → 1.0.3

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.
@@ -1,51 +0,0 @@
1
- import path from "node:path";
2
- import { build, loadConfigurationFromPath } from "@styleframe/loader";
3
- import { defineCommand } from "citty";
4
- import consola from "consola";
5
-
6
- export default defineCommand({
7
- meta: {
8
- name: "build",
9
- description: "Build Styleframe project from source files",
10
- },
11
- args: {
12
- entry: {
13
- type: "positional",
14
- description: "Entry point file(s) for the build",
15
- default: "styleframe.config.ts",
16
- valueHint: "path",
17
- },
18
- outputDir: {
19
- type: "string",
20
- description: "Output directory for built files",
21
- default: "styleframe",
22
- alias: ["o", "out"],
23
- valueHint: "path",
24
- },
25
- clean: {
26
- type: "boolean",
27
- description: "Clean output directory before build",
28
- default: false,
29
- },
30
- },
31
- async run({ args }) {
32
- consola.info(
33
- `Loading configuration from "${path.relative(process.cwd(), path.resolve(args.entry))}"...`,
34
- );
35
-
36
- const instance = await loadConfigurationFromPath(args.entry);
37
-
38
- consola.info("Building styleframe...");
39
-
40
- try {
41
- await build(instance, {
42
- outputDir: args.outputDir,
43
- clean: args.clean,
44
- });
45
-
46
- consola.success("Styleframe built successfully!");
47
- } catch (error) {
48
- consola.error("Failed to build Styleframe:", error);
49
- }
50
- },
51
- });
@@ -1,27 +0,0 @@
1
- import consola from "consola";
2
- import path from "path";
3
- import {
4
- loadFile as loadMagicastFile,
5
- writeFile as writeMagicastFile,
6
- } from "magicast";
7
- import { addNuxtModule } from "magicast/helpers";
8
-
9
- export async function initializeNuxtFrameworkFile(cwd: string) {
10
- consola.success("Nuxt environment detected.");
11
- const configFilePath = path.join(cwd, "nuxt.config.ts");
12
-
13
- try {
14
- const mod = await loadMagicastFile(configFilePath);
15
-
16
- addNuxtModule(mod, "styleframe/nuxt", "styleframe");
17
-
18
- await writeMagicastFile(mod, configFilePath);
19
-
20
- consola.success(`Updated Nuxt config file.`);
21
- } catch (error) {
22
- consola.error(`Failed to update Nuxt config file: ${error}`);
23
- consola.error(
24
- "Please add `'styleframe/nuxt'` to your nuxt modules array manually.",
25
- );
26
- }
27
- }
@@ -1,33 +0,0 @@
1
- import consola from "consola";
2
- import path from "path";
3
- import {
4
- loadFile as loadMagicastFile,
5
- writeFile as writeMagicastFile,
6
- } from "magicast";
7
- import { addVitePlugin } from "magicast/helpers";
8
-
9
- export async function initializeViteFrameworkFile(cwd: string) {
10
- consola.success("Vite environment detected.");
11
- const configFilePath = path.join(cwd, "vite.config.ts");
12
-
13
- try {
14
- const mod = await loadMagicastFile(configFilePath);
15
-
16
- addVitePlugin(mod, {
17
- from: "styleframe/plugins/vite",
18
- constructor: "styleframePlugin",
19
- imported: "default",
20
- });
21
-
22
- await writeMagicastFile(mod, configFilePath);
23
-
24
- consola.success(`Updated Vite config file.`);
25
- } catch (error) {
26
- consola.error(`Failed to update Vite config file.`);
27
- consola.log(error);
28
- console.log("");
29
- consola.log(
30
- "Please add `import styleframePlugin from 'styleframe/vite';` and register it manually.",
31
- );
32
- }
33
- }
@@ -1,88 +0,0 @@
1
- import consola from "consola";
2
- import { defineCommand } from "citty";
3
- import { readFile, writeFile } from "fs/promises";
4
- import path from "path";
5
- import { fileExists } from "../utils";
6
- import { initializeViteFrameworkFile } from "./init/vite";
7
- import { initializeNuxtFrameworkFile } from "./init/nuxt";
8
- import { DOCS_INSTALLATION_CUSTOM_URL } from "../constants";
9
-
10
- const styleframeConfigTemplate = `import { styleframe } from "styleframe";
11
-
12
- const s = styleframe();
13
-
14
- s.variable("color--primary", "blue");
15
-
16
- export default s;
17
- `;
18
-
19
- export async function initializeConfigFile(cwd: string) {
20
- const styleframeConfigPath = path.join(cwd, "styleframe.config.ts");
21
-
22
- if (await fileExists(styleframeConfigPath)) {
23
- consola.warn(
24
- `Skipped creating "styleframe.config.ts" because it already exists.`,
25
- );
26
- } else {
27
- await writeFile(styleframeConfigPath, styleframeConfigTemplate);
28
- consola.success(`Created "styleframe.config.ts".`);
29
- }
30
- }
31
-
32
- export async function addPackageJsonDependencies(cwd: string) {
33
- const packageJsonPath = path.join(cwd, "package.json");
34
- if (await fileExists(packageJsonPath)) {
35
- const packageJson = JSON.parse(await readFile(packageJsonPath, "utf8"));
36
-
37
- if (!packageJson.devDependencies) packageJson.devDependencies = {};
38
- packageJson.devDependencies["styleframe"] = "^1.0.0";
39
- packageJson.devDependencies["@styleframe/theme"] = "^1.0.0";
40
-
41
- await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
42
-
43
- consola.success(`Added dependencies to "package.json".`);
44
- } else {
45
- consola.warn(
46
- `Skipped adding styleframe to dependencies because package.json could not be found.`,
47
- );
48
- }
49
- }
50
-
51
- export async function initializeFrameworkFile(cwd: string) {
52
- if (await fileExists(path.join(cwd, "vite.config.ts"))) {
53
- await initializeViteFrameworkFile(cwd);
54
- } else if (await fileExists(path.join(cwd, "nuxt.config.ts"))) {
55
- await initializeNuxtFrameworkFile(cwd);
56
- } else {
57
- consola.warn(
58
- "No framework file detected. Read more about setting up styleframe manually.",
59
- DOCS_INSTALLATION_CUSTOM_URL,
60
- );
61
- }
62
- }
63
-
64
- export default defineCommand({
65
- meta: {
66
- name: "init",
67
- description: "Initialize a new styleframe project.",
68
- },
69
- args: {
70
- cwd: {
71
- type: "string",
72
- required: false,
73
- default: process.cwd(),
74
- description: "The directory where the project will be initialized",
75
- alias: ["d", "dir"],
76
- valueHint: "path",
77
- },
78
- },
79
- async run({ args }) {
80
- const { cwd } = args;
81
-
82
- consola.info("Initializing...");
83
-
84
- await initializeConfigFile(cwd);
85
- await addPackageJsonDependencies(cwd);
86
- await initializeFrameworkFile(cwd);
87
- },
88
- });
package/src/constants.ts DELETED
@@ -1,7 +0,0 @@
1
- export const HOMEPAGE_URL = "https://styleframe.dev";
2
- export const DOCS_URL = `${HOMEPAGE_URL}/docs`;
3
- export const DOCS_INSTALLATION_VITE_URL = `${DOCS_URL}/getting-started/installation/vite`;
4
- export const DOCS_MANUAL_INSTALLATION_VITE_URL = `${DOCS_URL}/getting-started/installation/manual/vite`;
5
- export const DOCS_INSTALLATION_NUXT_URL = `${DOCS_URL}/getting-started/installation/nuxt`;
6
- export const DOCS_MANUAL_INSTALLATION_NUXT_URL = `${DOCS_URL}/getting-started/installation/manual/nuxt`;
7
- export const DOCS_INSTALLATION_CUSTOM_URL = `${DOCS_URL}/getting-started/installation/custom`;
package/src/index.ts DELETED
@@ -1,18 +0,0 @@
1
- import { defineCommand, runMain } from "citty";
2
- import { description, version } from "./package";
3
-
4
- const main = defineCommand({
5
- meta: {
6
- name: "styleframe",
7
- version,
8
- description,
9
- },
10
- subCommands: {
11
- init: () => import("./commands/init").then((m) => m.default),
12
- build: () => import("./commands/build").then((m) => m.default),
13
- },
14
- });
15
-
16
- export default function run() {
17
- runMain(main);
18
- }
package/src/package.ts DELETED
@@ -1,2 +0,0 @@
1
- export const version = "1.0.1";
2
- export const description = "A command-line interface for styleframe.";
package/src/utils.ts DELETED
@@ -1,11 +0,0 @@
1
- import { access } from "node:fs/promises";
2
- import { constants } from "node:fs";
3
-
4
- export async function fileExists(path: string) {
5
- try {
6
- await access(path, constants.F_OK);
7
- return true;
8
- } catch {
9
- return false;
10
- }
11
- }
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "@styleframe/config-typescript",
3
- "compilerOptions": {
4
- "tsBuildInfoFile": ".tsbuildinfo"
5
- },
6
- "include": [
7
- "src/**/*.ts",
8
- "playground/**/*.ts",
9
- "tsdown.config.ts",
10
- "vite.config.ts"
11
- ]
12
- }
package/vite.config.ts DELETED
@@ -1,13 +0,0 @@
1
- import { createViteConfig } from "@styleframe/config-vite";
2
- import { VitePluginNode } from "vite-plugin-node";
3
-
4
- const __dirname = new URL(".", import.meta.url).pathname;
5
-
6
- export default createViteConfig("cli", __dirname, {
7
- plugins: [
8
- VitePluginNode({
9
- appPath: "./src/index.ts",
10
- adapter: "express",
11
- }),
12
- ],
13
- });