solidui-cli 0.1.2 → 0.1.4

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,85 +0,0 @@
1
- import { transformFromAstSync } from "@babel/core"
2
- import { type ParserOptions, parse } from "@babel/parser"
3
- // @ts-ignore
4
- import transformTypescript from "@babel/plugin-transform-typescript"
5
- import * as recast from "recast"
6
-
7
- // TODO.
8
- // I'm using recast for the AST here.
9
- // Figure out if ts-morph AST is compatible with Babel.
10
-
11
- // This is a copy of the babel options from recast/parser.
12
- // The goal here is to tolerate as much syntax as possible.
13
- // We want to be able to parse any valid tsx code.
14
- // See https://github.com/benjamn/recast/blob/master/parsers/_babel_options.ts.
15
- const PARSE_OPTIONS: ParserOptions = {
16
- sourceType: "module",
17
- allowImportExportEverywhere: true,
18
- allowReturnOutsideFunction: true,
19
- startLine: 1,
20
- tokens: true,
21
- plugins: [
22
- "asyncGenerators",
23
- "bigInt",
24
- "classPrivateMethods",
25
- "classPrivateProperties",
26
- "classProperties",
27
- "classStaticBlock",
28
- "decimal",
29
- "decorators-legacy",
30
- "doExpressions",
31
- "dynamicImport",
32
- "exportDefaultFrom",
33
- "exportNamespaceFrom",
34
- "functionBind",
35
- "functionSent",
36
- "importAssertions",
37
- "importMeta",
38
- "nullishCoalescingOperator",
39
- "numericSeparator",
40
- "objectRestSpread",
41
- "optionalCatchBinding",
42
- "optionalChaining",
43
- [
44
- "pipelineOperator",
45
- {
46
- proposal: "minimal"
47
- }
48
- ],
49
- [
50
- "recordAndTuple",
51
- {
52
- syntaxType: "hash"
53
- }
54
- ],
55
- "throwExpressions",
56
- "topLevelAwait",
57
- "v8intrinsic",
58
- "typescript",
59
- "jsx"
60
- ]
61
- }
62
-
63
- export const transpileTS = (source: string) => {
64
- const ast = recast.parse(source, {
65
- parser: {
66
- parse: (code: string) => {
67
- return parse(code, PARSE_OPTIONS)
68
- }
69
- }
70
- })
71
-
72
- const result = transformFromAstSync(ast, source, {
73
- cloneInputAst: false,
74
- code: false,
75
- ast: true,
76
- plugins: [transformTypescript],
77
- configFile: false
78
- })
79
-
80
- if (!result || !result.ast) {
81
- throw new Error("Failed to transform JSX")
82
- }
83
-
84
- return recast.print(result.ast).code
85
- }
package/src/lib/types.ts DELETED
@@ -1,40 +0,0 @@
1
- import type { Output } from "valibot"
2
- import { boolean, object, string } from "valibot"
3
-
4
- export enum CommandTypes {
5
- "init",
6
- "add"
7
- }
8
-
9
- export interface ComponentFile {
10
- name: string
11
- content: string
12
- }
13
-
14
- export interface RegistryComponentResponse {
15
- name: string
16
- dependencies: string[]
17
- registryDependencies: string[]
18
- files: ComponentFile[]
19
- type: string
20
- }
21
-
22
- export type RegistryComponentsList = {
23
- name: string
24
- files: string[]
25
- dependencies: string[]
26
- type: string
27
- }[]
28
-
29
- export const configSchema = object({
30
- tsx: boolean(),
31
- componentDir: string(),
32
- tailwind: object({
33
- config: string(),
34
- css: string()
35
- }),
36
- aliases: object({
37
- path: string()
38
- })
39
- })
40
- export type Config = Output<typeof configSchema>
package/src/lib/utils.ts DELETED
@@ -1,56 +0,0 @@
1
- import { execSync } from "child_process"
2
- import { readFile } from "fs"
3
-
4
- import { log, spinner } from "@clack/prompts"
5
- import { detect } from "detect-package-manager"
6
-
7
- export function readJsonFile(
8
- filePath: string,
9
- callback: (error: Error | null, data: unknown | null) => void
10
- ): void {
11
- readFile(filePath, "utf8", (err, data) => {
12
- if (err) {
13
- callback(err, null)
14
- return
15
- }
16
-
17
- try {
18
- const jsonObject = JSON.parse(data)
19
- callback(null, jsonObject)
20
- } catch (parseError) {
21
- callback(parseError as Error, null)
22
- }
23
- })
24
- }
25
-
26
- export function runCommand(command: string, message?: string, endMessage?: string) {
27
- try {
28
- const indicator = spinner()
29
- indicator.start(message)
30
-
31
- execSync(command)
32
-
33
- indicator.stop(endMessage ?? "Done")
34
- } catch (error) {
35
- log.error(`${error}`)
36
- }
37
- }
38
-
39
- export function removeExtension(value: string) {
40
- const splitWords = value.split(".")
41
-
42
- return splitWords[0]
43
- }
44
-
45
- export async function installPackages(...packages: string[]) {
46
- const packageManager = await detect()
47
-
48
- switch (packageManager) {
49
- case "yarn":
50
- case "pnpm":
51
- runCommand(`${packageManager} add ${packages.join(" ")}`, "Installing dependencies")
52
- break
53
- default:
54
- runCommand(`${packageManager} install ${packages.join(" ")}`, "Installing dependencies")
55
- }
56
- }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "exclude": ["node_modules", "dist"],
3
- "compilerOptions": {
4
- "allowSyntheticDefaultImports": true,
5
- "esModuleInterop": false,
6
- "target": "ESNext",
7
- "module": "ESNext",
8
- "moduleResolution": "Node",
9
- "noEmit": false,
10
- "allowArbitraryExtensions": true,
11
- "strict": true,
12
- "baseUrl": "./",
13
- "outDir": "./dist",
14
- "paths": {
15
- "~/*": ["./src/*"]
16
- }
17
- }
18
- }
package/tsup.config.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "https://cdn.jsdelivr.net/npm/tsup/schema.json",
3
- "entry": ["src/index.ts"],
4
- "splitting": false,
5
- "clean": true,
6
- "format": "esm"
7
- }