reset-framework-cli 0.2.0 → 1.0.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 +5 -5
- package/src/commands/init.js +14 -25
- package/src/lib/project.js +39 -6
- package/templates/basic/frontend/package.json +1 -1
- package/templates/basic/frontend/src/App.tsx +13 -9
- package/templates/basic/frontend/src/lib/reset.ts +1 -16
- package/templates/basic/frontend/tsconfig.app.json +5 -1
- package/templates/basic/frontend/vite.config.ts +10 -1
- package/templates/basic/reset.config.json +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reset-framework-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Command-line tooling for Reset Framework.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"node": ">=20.19.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@reset-framework/native": "0.
|
|
15
|
-
"@reset-framework/schema": "0.
|
|
16
|
-
"@reset-framework/sdk": "0.
|
|
14
|
+
"@reset-framework/native": "1.0.1",
|
|
15
|
+
"@reset-framework/schema": "1.0.1",
|
|
16
|
+
"@reset-framework/sdk": "1.0.1"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"reset-framework-cli": "
|
|
19
|
+
"reset-framework-cli": "src/index.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"src",
|
package/src/commands/init.js
CHANGED
|
@@ -25,22 +25,7 @@ import {
|
|
|
25
25
|
withPromptSession
|
|
26
26
|
} from "../lib/ui.js"
|
|
27
27
|
|
|
28
|
-
const sdkRuntimeReexport = `export
|
|
29
|
-
createResetClient,
|
|
30
|
-
getResetRuntime,
|
|
31
|
-
invoke,
|
|
32
|
-
invokeRaw,
|
|
33
|
-
isResetRuntimeAvailable,
|
|
34
|
-
ResetRuntimeUnavailableError,
|
|
35
|
-
} from '@reset-framework/sdk'
|
|
36
|
-
|
|
37
|
-
export type {
|
|
38
|
-
ResetInvokeError,
|
|
39
|
-
ResetInvokeResponse,
|
|
40
|
-
ResetInvokeSuccess,
|
|
41
|
-
ResetRuntime,
|
|
42
|
-
ResetRuntimeWindow,
|
|
43
|
-
} from '@reset-framework/sdk'
|
|
28
|
+
const sdkRuntimeReexport = `export * from '@reset-framework/sdk'
|
|
44
29
|
`
|
|
45
30
|
|
|
46
31
|
const standaloneViteConfig = `import { defineConfig } from 'vite'
|
|
@@ -100,29 +85,33 @@ body {
|
|
|
100
85
|
`
|
|
101
86
|
|
|
102
87
|
const tailwindAppTsx = `import { useEffect, useState } from 'react'
|
|
103
|
-
import {
|
|
88
|
+
import { reset } from './lib/reset'
|
|
104
89
|
|
|
105
90
|
function App() {
|
|
106
91
|
const [count, setCount] = useState(0)
|
|
107
92
|
const [appName, setAppName] = useState('Reset App')
|
|
93
|
+
const [appVersion, setAppVersion] = useState('0.0.0')
|
|
108
94
|
const [platform, setPlatform] = useState('unknown')
|
|
95
|
+
const [bridgeVersion, setBridgeVersion] = useState('1')
|
|
109
96
|
|
|
110
97
|
useEffect(() => {
|
|
111
98
|
let cancelled = false
|
|
112
99
|
|
|
113
100
|
async function loadRuntimeInfo() {
|
|
114
101
|
try {
|
|
115
|
-
const [
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
const [appInfo, runtimeInfo] = await Promise.all([
|
|
103
|
+
reset.app.getInfo(),
|
|
104
|
+
reset.runtime.getInfo(),
|
|
118
105
|
])
|
|
119
106
|
|
|
120
107
|
if (cancelled) {
|
|
121
108
|
return
|
|
122
109
|
}
|
|
123
110
|
|
|
124
|
-
setAppName(name)
|
|
125
|
-
|
|
111
|
+
setAppName(appInfo.name)
|
|
112
|
+
setAppVersion(appInfo.version)
|
|
113
|
+
setPlatform(runtimeInfo.platform)
|
|
114
|
+
setBridgeVersion(runtimeInfo.bridgeVersion)
|
|
126
115
|
} catch (error) {
|
|
127
116
|
console.error('Failed to load runtime info', error)
|
|
128
117
|
}
|
|
@@ -139,7 +128,7 @@ function App() {
|
|
|
139
128
|
<main className="min-h-screen bg-stone-950 text-stone-100">
|
|
140
129
|
<div className="mx-auto flex min-h-screen max-w-6xl flex-col px-6 py-12 lg:px-10">
|
|
141
130
|
<div className="inline-flex w-fit items-center rounded-full border border-white/10 bg-white/5 px-4 py-2 text-sm tracking-[0.18em] text-stone-300 uppercase">
|
|
142
|
-
{appName} on {platform}
|
|
131
|
+
{appName} v{appVersion} on {platform}
|
|
143
132
|
</div>
|
|
144
133
|
|
|
145
134
|
<div className="mt-12 grid gap-12 lg:grid-cols-[minmax(0,1.4fr)_minmax(20rem,0.8fr)] lg:items-end">
|
|
@@ -158,8 +147,8 @@ function App() {
|
|
|
158
147
|
|
|
159
148
|
<section className="rounded-[2rem] border border-white/10 bg-white/5 p-6 shadow-2xl shadow-black/20 backdrop-blur">
|
|
160
149
|
<div className="flex items-center justify-between text-sm text-stone-400">
|
|
161
|
-
<span>
|
|
162
|
-
<span>
|
|
150
|
+
<span>Runtime bridge</span>
|
|
151
|
+
<span>bridge v{bridgeVersion}</span>
|
|
163
152
|
</div>
|
|
164
153
|
<div className="mt-6 rounded-2xl border border-white/10 bg-black/30 p-5">
|
|
165
154
|
<div className="text-xs uppercase tracking-[0.24em] text-stone-500">
|
package/src/lib/project.js
CHANGED
|
@@ -120,21 +120,42 @@ function resolvePackageInfo(packageName, fallbackRoot) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
function resolveWorkspacePackageInfo(packageName, workspaceRoot, fallbackInfo) {
|
|
124
|
+
const packageJsonPath = path.join(workspaceRoot, "package.json")
|
|
125
|
+
|
|
126
|
+
if (!existsSync(packageJsonPath)) {
|
|
127
|
+
return fallbackInfo
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const manifest = readJsonFile(packageJsonPath)
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
packageName: manifest.name ?? packageName,
|
|
134
|
+
packageRoot: workspaceRoot,
|
|
135
|
+
packageJsonPath,
|
|
136
|
+
version: manifest.version ?? fallbackInfo.version,
|
|
137
|
+
localFallback: true
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
123
141
|
export function resolveFrameworkPaths() {
|
|
124
142
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url))
|
|
125
143
|
const cliDir = path.resolve(moduleDir, "../..")
|
|
126
144
|
const packagesDir = path.resolve(cliDir, "..")
|
|
127
|
-
const nativePackage =
|
|
145
|
+
const nativePackage = resolveWorkspacePackageInfo(
|
|
128
146
|
"@reset-framework/native",
|
|
129
|
-
path.join(packagesDir, "native")
|
|
147
|
+
path.join(packagesDir, "native"),
|
|
148
|
+
resolvePackageInfo("@reset-framework/native", path.join(packagesDir, "native"))
|
|
130
149
|
)
|
|
131
|
-
const sdkPackage =
|
|
150
|
+
const sdkPackage = resolveWorkspacePackageInfo(
|
|
132
151
|
"@reset-framework/sdk",
|
|
133
|
-
path.join(packagesDir, "sdk")
|
|
152
|
+
path.join(packagesDir, "sdk"),
|
|
153
|
+
resolvePackageInfo("@reset-framework/sdk", path.join(packagesDir, "sdk"))
|
|
134
154
|
)
|
|
135
|
-
const schemaPackage =
|
|
155
|
+
const schemaPackage = resolveWorkspacePackageInfo(
|
|
136
156
|
"@reset-framework/schema",
|
|
137
|
-
path.join(packagesDir, "schema")
|
|
157
|
+
path.join(packagesDir, "schema"),
|
|
158
|
+
resolvePackageInfo("@reset-framework/schema", path.join(packagesDir, "schema"))
|
|
138
159
|
)
|
|
139
160
|
const isWorkspaceLayout = [nativePackage, sdkPackage, schemaPackage].every((pkg) =>
|
|
140
161
|
isPathInside(packagesDir, pkg.packageRoot)
|
|
@@ -254,6 +275,7 @@ export function validateResetConfig(rawConfig) {
|
|
|
254
275
|
const frontend = optionalObject(rawConfig, "frontend")
|
|
255
276
|
const build = optionalObject(rawConfig, "build")
|
|
256
277
|
const project = optionalObject(rawConfig, "project")
|
|
278
|
+
const security = optionalObject(rawConfig, "security")
|
|
257
279
|
const windowConfig = optionalObject(rawConfig, "window")
|
|
258
280
|
|
|
259
281
|
return {
|
|
@@ -276,6 +298,17 @@ export function validateResetConfig(rawConfig) {
|
|
|
276
298
|
},
|
|
277
299
|
build: {
|
|
278
300
|
outputDir: optionalString(build, "outputDir", ".reset/build")
|
|
301
|
+
},
|
|
302
|
+
security: {
|
|
303
|
+
permissions: Array.isArray(security.permissions)
|
|
304
|
+
? security.permissions.map((value) => {
|
|
305
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
306
|
+
throw new Error("Missing or invalid string field 'security.permissions'")
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return value
|
|
310
|
+
})
|
|
311
|
+
: []
|
|
279
312
|
}
|
|
280
313
|
}
|
|
281
314
|
}
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
import './App.css'
|
|
3
|
-
import {
|
|
3
|
+
import { reset } from './lib/reset'
|
|
4
4
|
|
|
5
5
|
function App() {
|
|
6
6
|
const [count, setCount] = useState(0)
|
|
7
7
|
const [appName, setAppName] = useState('Reset Framework')
|
|
8
|
+
const [appVersion, setAppVersion] = useState('0.0.0')
|
|
8
9
|
const [platform, setPlatform] = useState('unknown')
|
|
10
|
+
const [bridgeVersion, setBridgeVersion] = useState('1')
|
|
9
11
|
|
|
10
12
|
useEffect(() => {
|
|
11
13
|
let cancelled = false
|
|
12
14
|
|
|
13
15
|
async function loadRuntimeInfo() {
|
|
14
16
|
try {
|
|
15
|
-
const [
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const [appInfo, runtimeInfo] = await Promise.all([
|
|
18
|
+
reset.app.getInfo(),
|
|
19
|
+
reset.runtime.getInfo(),
|
|
18
20
|
])
|
|
19
21
|
|
|
20
22
|
if (cancelled) {
|
|
21
23
|
return
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
setAppName(name)
|
|
25
|
-
|
|
26
|
+
setAppName(appInfo.name)
|
|
27
|
+
setAppVersion(appInfo.version)
|
|
28
|
+
setPlatform(runtimeInfo.platform)
|
|
29
|
+
setBridgeVersion(runtimeInfo.bridgeVersion)
|
|
26
30
|
} catch (error) {
|
|
27
31
|
console.error('Failed to load runtime info', error)
|
|
28
32
|
}
|
|
@@ -40,7 +44,7 @@ function App() {
|
|
|
40
44
|
<div className="ambient-background"></div>
|
|
41
45
|
|
|
42
46
|
<div className="content-wrapper">
|
|
43
|
-
<div className="badge">{appName} on {platform}</div>
|
|
47
|
+
<div className="badge">{appName} v{appVersion} on {platform}</div>
|
|
44
48
|
|
|
45
49
|
<h1 className="title">
|
|
46
50
|
Native performance.<br />
|
|
@@ -57,12 +61,12 @@ function App() {
|
|
|
57
61
|
Count is {count}
|
|
58
62
|
</button>
|
|
59
63
|
<a href="#" className="secondary-btn">
|
|
60
|
-
|
|
64
|
+
Bridge v{bridgeVersion}
|
|
61
65
|
</a>
|
|
62
66
|
</div>
|
|
63
67
|
|
|
64
68
|
<div className="terminal-snippet">
|
|
65
|
-
<code>
|
|
69
|
+
<code>reset-framework-cli create-app my-app</code>
|
|
66
70
|
</div>
|
|
67
71
|
</div>
|
|
68
72
|
</main>
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
createResetClient,
|
|
3
|
-
getResetRuntime,
|
|
4
|
-
invoke,
|
|
5
|
-
invokeRaw,
|
|
6
|
-
isResetRuntimeAvailable,
|
|
7
|
-
ResetRuntimeUnavailableError,
|
|
8
|
-
} from '@reset-framework/sdk'
|
|
9
|
-
|
|
10
|
-
export type {
|
|
11
|
-
ResetInvokeError,
|
|
12
|
-
ResetInvokeResponse,
|
|
13
|
-
ResetInvokeSuccess,
|
|
14
|
-
ResetRuntime,
|
|
15
|
-
ResetRuntimeWindow,
|
|
16
|
-
} from '@reset-framework/sdk'
|
|
1
|
+
export * from '@reset-framework/sdk'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
+
"baseUrl": ".",
|
|
4
5
|
"target": "ES2023",
|
|
5
6
|
"useDefineForClassFields": true,
|
|
6
7
|
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
@@ -18,7 +19,10 @@
|
|
|
18
19
|
"noUnusedParameters": true,
|
|
19
20
|
"erasableSyntaxOnly": true,
|
|
20
21
|
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"noUncheckedSideEffectImports": true
|
|
22
|
+
"noUncheckedSideEffectImports": true,
|
|
23
|
+
"paths": {
|
|
24
|
+
"@reset-framework/sdk": ["../../../../sdk/src/index.d.ts"]
|
|
25
|
+
}
|
|
22
26
|
},
|
|
23
27
|
"include": ["src"]
|
|
24
28
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
2
3
|
import react from '@vitejs/plugin-react'
|
|
4
|
+
import { defineConfig } from 'vite'
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
3
7
|
|
|
4
8
|
export default defineConfig({
|
|
5
9
|
plugins: [react()],
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@reset-framework/sdk': path.resolve(__dirname, '../../../../sdk/src/index.js'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
6
15
|
})
|
|
@@ -25,5 +25,31 @@
|
|
|
25
25
|
},
|
|
26
26
|
"build": {
|
|
27
27
|
"outputDir": ".reset/build"
|
|
28
|
+
},
|
|
29
|
+
"security": {
|
|
30
|
+
"permissions": [
|
|
31
|
+
"app.*",
|
|
32
|
+
"runtime.*",
|
|
33
|
+
"window.*",
|
|
34
|
+
"dialog.*",
|
|
35
|
+
"fs.*",
|
|
36
|
+
"path.*",
|
|
37
|
+
"shell.*",
|
|
38
|
+
"clipboard.*",
|
|
39
|
+
"notification.*",
|
|
40
|
+
"screen.*",
|
|
41
|
+
"storage.*",
|
|
42
|
+
"webview.*",
|
|
43
|
+
"event.*",
|
|
44
|
+
"crypto.*",
|
|
45
|
+
"process.*",
|
|
46
|
+
"power.*",
|
|
47
|
+
"menu.*",
|
|
48
|
+
"tray.*",
|
|
49
|
+
"shortcut.*",
|
|
50
|
+
"protocol.*",
|
|
51
|
+
"updater.*",
|
|
52
|
+
"net.*"
|
|
53
|
+
]
|
|
28
54
|
}
|
|
29
55
|
}
|