@styleframe/cli 1.0.1 → 1.0.2
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/.tsbuildinfo +1 -1
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/package.json +12 -7
- package/{src/playground → playground}/build.ts +1 -1
- package/{src/playground → playground}/init.ts +6 -1
- package/playground/vite.config.template.ts +5 -0
- package/src/commands/build.ts +17 -11
- package/src/commands/init/nuxt.ts +27 -0
- package/src/commands/init/vite.ts +33 -0
- package/src/commands/init.ts +19 -5
- package/src/constants.ts +7 -0
- package/src/package.ts +1 -1
- package/tsconfig.json +6 -1
- package/src/playground/styleframe/index.css +0 -3
- /package/{src/playground → playground}/package.template.json +0 -0
- /package/{src/playground → playground}/styleframe.config.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @styleframe/cli
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#30](https://github.com/styleframe-dev/styleframe/pull/30) [`68cd004`](https://github.com/styleframe-dev/styleframe/commit/68cd004b04395797876b5e805c0b910d6b665f35) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: Add support for modifying Vite and Nuxt configuration files
|
|
8
|
+
feat: Add fallback installation guide links
|
|
9
|
+
- Updated dependencies [[`68cd004`](https://github.com/styleframe-dev/styleframe/commit/68cd004b04395797876b5e805c0b910d6b665f35)]:
|
|
10
|
+
- @styleframe/loader@1.0.2
|
|
11
|
+
|
|
3
12
|
## 1.0.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alex Grozav
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A command-line interface for styleframe.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -16,18 +16,20 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"citty": "^0.1.6",
|
|
18
18
|
"consola": "^3.0.0-2",
|
|
19
|
-
"
|
|
19
|
+
"magicast": "^0.5.0",
|
|
20
|
+
"@styleframe/loader": "^1.0.2"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
23
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
22
24
|
"tsx": "^4.20.6",
|
|
23
25
|
"typescript": "^5.8.3",
|
|
24
26
|
"vite": "^7.0.6",
|
|
25
27
|
"vite-plugin-dts": "^4.5.4",
|
|
26
28
|
"vite-plugin-node": "^7.0.0",
|
|
27
29
|
"vitest": "^3.2.4",
|
|
28
|
-
"@styleframe/config-vite": "^1.0.1",
|
|
29
30
|
"@styleframe/config-typescript": "^1.0.1",
|
|
30
|
-
"@styleframe/core": "^1.0.1"
|
|
31
|
+
"@styleframe/core": "^1.0.1",
|
|
32
|
+
"@styleframe/config-vite": "^1.0.1"
|
|
31
33
|
},
|
|
32
34
|
"homepage": "https://github.com/styleframe-dev/styleframe#readme",
|
|
33
35
|
"bugs": {
|
|
@@ -38,14 +40,17 @@
|
|
|
38
40
|
"url": "git+https://github.com/styleframe-dev/styleframe.git"
|
|
39
41
|
},
|
|
40
42
|
"author": "Alex Grozav <alex@styleframe.dev>",
|
|
43
|
+
"overrides": {
|
|
44
|
+
"vite": "npm:rolldown-vite@latest"
|
|
45
|
+
},
|
|
41
46
|
"scripts": {
|
|
42
47
|
"dev": "vite build --watch",
|
|
43
48
|
"prebuild": "tsx ./scripts/prebuild.ts",
|
|
44
49
|
"build": "pnpm run prebuild && pnpm typecheck && vite build",
|
|
45
50
|
"typecheck": "tsc --noEmit",
|
|
46
|
-
"test": "vitest run",
|
|
51
|
+
"test": "vitest run --passWithNoTests",
|
|
47
52
|
"test:dev": "vitest --watch",
|
|
48
|
-
"playground:init": "tsx
|
|
49
|
-
"playground:build": "tsx
|
|
53
|
+
"playground:init": "tsx playground/init.ts",
|
|
54
|
+
"playground:build": "tsx playground/build.ts"
|
|
50
55
|
}
|
|
51
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { copyFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import init from "../commands/init";
|
|
3
|
+
import init from "../src/commands/init";
|
|
4
4
|
|
|
5
5
|
const __dirname = new URL(".", import.meta.url).pathname;
|
|
6
6
|
|
|
@@ -10,6 +10,11 @@ const __dirname = new URL(".", import.meta.url).pathname;
|
|
|
10
10
|
path.join(__dirname, "package.json"),
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
+
await copyFile(
|
|
14
|
+
path.join(__dirname, "vite.config.template.ts"),
|
|
15
|
+
path.join(__dirname, "vite.config.ts"),
|
|
16
|
+
);
|
|
17
|
+
|
|
13
18
|
// biome-ignore lint/suspicious/noExplicitAny: No need for explicit type
|
|
14
19
|
await init.run?.({ args: { cwd: __dirname } } as any);
|
|
15
20
|
})();
|
package/src/commands/build.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { build,
|
|
2
|
+
import { build, loadConfigurationFromPath } from "@styleframe/loader";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
|
|
@@ -22,24 +22,30 @@ export default defineCommand({
|
|
|
22
22
|
alias: ["o", "out"],
|
|
23
23
|
valueHint: "path",
|
|
24
24
|
},
|
|
25
|
+
clean: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
description: "Clean output directory before build",
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
25
30
|
},
|
|
26
31
|
async run({ args }) {
|
|
27
|
-
const entryPath = path.resolve(args.entry);
|
|
28
|
-
const cwd = path.dirname(entryPath);
|
|
29
|
-
const name = path.basename(entryPath).replace(/(\.config)?(\.ts)?$/, "");
|
|
30
|
-
|
|
31
32
|
consola.info(
|
|
32
|
-
`Loading configuration from "${path.relative(process.cwd(),
|
|
33
|
+
`Loading configuration from "${path.relative(process.cwd(), path.resolve(args.entry))}"...`,
|
|
33
34
|
);
|
|
34
35
|
|
|
35
|
-
const instance = await
|
|
36
|
+
const instance = await loadConfigurationFromPath(args.entry);
|
|
36
37
|
|
|
37
38
|
consola.info("Building styleframe...");
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
try {
|
|
41
|
+
await build(instance, {
|
|
42
|
+
outputDir: args.outputDir,
|
|
43
|
+
clean: args.clean,
|
|
44
|
+
});
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
consola.success("Styleframe built successfully!");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
consola.error("Failed to build Styleframe:", error);
|
|
49
|
+
}
|
|
44
50
|
},
|
|
45
51
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|
package/src/commands/init.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { defineCommand } from "citty";
|
|
|
3
3
|
import { readFile, writeFile } from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
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";
|
|
6
9
|
|
|
7
10
|
const styleframeConfigTemplate = `import { styleframe } from "styleframe";
|
|
8
11
|
|
|
@@ -31,12 +34,9 @@ export async function addPackageJsonDependencies(cwd: string) {
|
|
|
31
34
|
if (await fileExists(packageJsonPath)) {
|
|
32
35
|
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf8"));
|
|
33
36
|
|
|
34
|
-
if (!packageJson.dependencies) packageJson.dependencies = {};
|
|
35
|
-
packageJson.dependencies["styleframe"] = "^1.0.0";
|
|
36
|
-
packageJson.dependencies["@styleframe/theme"] = "^1.0.0";
|
|
37
|
-
|
|
38
37
|
if (!packageJson.devDependencies) packageJson.devDependencies = {};
|
|
39
|
-
packageJson.devDependencies["
|
|
38
|
+
packageJson.devDependencies["styleframe"] = "^1.0.0";
|
|
39
|
+
packageJson.devDependencies["@styleframe/theme"] = "^1.0.0";
|
|
40
40
|
|
|
41
41
|
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
42
42
|
|
|
@@ -48,6 +48,19 @@ export async function addPackageJsonDependencies(cwd: string) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
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
|
+
|
|
51
64
|
export default defineCommand({
|
|
52
65
|
meta: {
|
|
53
66
|
name: "init",
|
|
@@ -70,5 +83,6 @@ export default defineCommand({
|
|
|
70
83
|
|
|
71
84
|
await initializeConfigFile(cwd);
|
|
72
85
|
await addPackageJsonDependencies(cwd);
|
|
86
|
+
await initializeFrameworkFile(cwd);
|
|
73
87
|
},
|
|
74
88
|
});
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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/package.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "1.0.
|
|
1
|
+
export const version = "1.0.1";
|
|
2
2
|
export const description = "A command-line interface for styleframe.";
|
package/tsconfig.json
CHANGED
|
File without changes
|
|
File without changes
|