scripting-cli 1.0.6 → 1.0.8
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/dist/createScript.js +21 -20
- package/package.json +1 -1
- package/src/createScript.ts +21 -20
package/dist/createScript.js
CHANGED
|
@@ -43,8 +43,8 @@ function createEntryFile(scriptName) {
|
|
|
43
43
|
yield (0, promises_1.writeFile)(filePath, `import { Column, CupertinoNavigationBar, CupertinoPageScaffold, Text, Container, useCupertinoColors, navigator, GestureDetector, Script, Center, CupertinoButton, } from 'scripting'
|
|
44
44
|
|
|
45
45
|
function App() {
|
|
46
|
-
const
|
|
47
|
-
const backgroundColor =
|
|
46
|
+
const colors = useCupertinoColors()
|
|
47
|
+
const backgroundColor = colors.systemBackground
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
50
|
<CupertinoPageScaffold
|
|
@@ -59,7 +59,7 @@ function App() {
|
|
|
59
59
|
>
|
|
60
60
|
<Center>
|
|
61
61
|
<Text
|
|
62
|
-
color={
|
|
62
|
+
color={colors.label}
|
|
63
63
|
>Welcome to Scripting!</Text>
|
|
64
64
|
</Center>
|
|
65
65
|
</CupertinoPageScaffold>
|
|
@@ -88,7 +88,7 @@ function createPackageJson(scriptName) {
|
|
|
88
88
|
"version": "0.0.1",
|
|
89
89
|
"private": true,
|
|
90
90
|
"scripts": {
|
|
91
|
-
"
|
|
91
|
+
"start": "npx scripting-cli dev",
|
|
92
92
|
"build": "npx scripting-cli build"
|
|
93
93
|
}
|
|
94
94
|
}`, 'utf-8');
|
|
@@ -99,13 +99,13 @@ function createReadme(scriptName) {
|
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
100
|
console.log(` > Creating ${scriptName}/README.md ...`);
|
|
101
101
|
const filePath = node_path_1.default.join(getScriptDir(scriptName), 'README.md');
|
|
102
|
-
yield (0, promises_1.writeFile)(filePath, `# ${scriptName} - A Scripting
|
|
102
|
+
yield (0, promises_1.writeFile)(filePath, `# ${scriptName} - A script for Scripting app.
|
|
103
103
|
|
|
104
104
|
## Start dev server
|
|
105
105
|
|
|
106
|
-
\`npm
|
|
106
|
+
\`npm start\`
|
|
107
107
|
|
|
108
|
-
## Build
|
|
108
|
+
## Build Script
|
|
109
109
|
|
|
110
110
|
\`npm run build\`
|
|
111
111
|
`, 'utf-8');
|
|
@@ -129,25 +129,26 @@ function createTSConfig(scriptName) {
|
|
|
129
129
|
"forceConsistentCasingInFileNames": true,
|
|
130
130
|
"noFallthroughCasesInSwitch": true,
|
|
131
131
|
"module": "CommonJS",
|
|
132
|
+
"resolveJsonModule": true,
|
|
132
133
|
"skipLibCheck": true,
|
|
133
134
|
"jsx": "react",
|
|
134
135
|
"jsxFactory": "createElement",
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// ]
|
|
141
|
-
// }
|
|
136
|
+
"paths": {
|
|
137
|
+
"scripting": [
|
|
138
|
+
"./types/scripting.d.ts"
|
|
139
|
+
]
|
|
140
|
+
}
|
|
142
141
|
},
|
|
143
142
|
"include": [
|
|
144
|
-
"src"
|
|
143
|
+
"src",
|
|
144
|
+
"types/assets.d.ts",
|
|
145
|
+
"types/global.d.ts",
|
|
145
146
|
],
|
|
146
147
|
}`, 'utf-8');
|
|
147
148
|
console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/tsconfig.json`));
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
|
-
function
|
|
151
|
+
function copyDtsAsset(scriptName, fileName) {
|
|
151
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
153
|
console.log(` > Creating ${scriptName}/types/${fileName}.d.ts ...`);
|
|
153
154
|
yield (0, promises_1.copyFile)(node_path_1.default.join(__dirname, `../public/${fileName}.d.ts`), node_path_1.default.join(getScriptDir(scriptName), `types/${fileName}.d.ts`));
|
|
@@ -156,9 +157,9 @@ function copyAsset(scriptName, fileName) {
|
|
|
156
157
|
}
|
|
157
158
|
function copyAssets(scriptName) {
|
|
158
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
yield
|
|
160
|
-
yield
|
|
161
|
-
yield
|
|
160
|
+
yield copyDtsAsset(scriptName, 'scripting');
|
|
161
|
+
yield copyDtsAsset(scriptName, 'global');
|
|
162
|
+
yield copyDtsAsset(scriptName, 'assets');
|
|
162
163
|
// console.log(` > Creating ${scriptName}/src/svgs/logo.svg ...`)
|
|
163
164
|
// await copyFile(
|
|
164
165
|
// path.join(__dirname, '../public/logo.svg'),
|
|
@@ -199,7 +200,7 @@ function createScript(scriptName) {
|
|
|
199
200
|
yield copyAssets(scriptName);
|
|
200
201
|
yield createVSCodeSettings(scriptName);
|
|
201
202
|
installDeps(scriptName);
|
|
202
|
-
console.log(`All done! Run ${chalk_1.default.bold(chalk_1.default.green(`cd ${scriptName} && npm
|
|
203
|
+
console.log(`All done! Run ${chalk_1.default.bold(chalk_1.default.green(`cd ${scriptName} && npm start`))} to start the dev server.`);
|
|
203
204
|
}
|
|
204
205
|
catch (e) {
|
|
205
206
|
console.log(chalk_1.default.red(`✖️ Create script failed: ${e.message}`));
|
package/package.json
CHANGED
package/src/createScript.ts
CHANGED
|
@@ -34,8 +34,8 @@ async function createEntryFile(scriptName: string) {
|
|
|
34
34
|
`import { Column, CupertinoNavigationBar, CupertinoPageScaffold, Text, Container, useCupertinoColors, navigator, GestureDetector, Script, Center, CupertinoButton, } from 'scripting'
|
|
35
35
|
|
|
36
36
|
function App() {
|
|
37
|
-
const
|
|
38
|
-
const backgroundColor =
|
|
37
|
+
const colors = useCupertinoColors()
|
|
38
|
+
const backgroundColor = colors.systemBackground
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<CupertinoPageScaffold
|
|
@@ -50,7 +50,7 @@ function App() {
|
|
|
50
50
|
>
|
|
51
51
|
<Center>
|
|
52
52
|
<Text
|
|
53
|
-
color={
|
|
53
|
+
color={colors.label}
|
|
54
54
|
>Welcome to Scripting!</Text>
|
|
55
55
|
</Center>
|
|
56
56
|
</CupertinoPageScaffold>
|
|
@@ -87,7 +87,7 @@ async function createPackageJson(scriptName: string) {
|
|
|
87
87
|
"version": "0.0.1",
|
|
88
88
|
"private": true,
|
|
89
89
|
"scripts": {
|
|
90
|
-
"
|
|
90
|
+
"start": "npx scripting-cli dev",
|
|
91
91
|
"build": "npx scripting-cli build"
|
|
92
92
|
}
|
|
93
93
|
}`,
|
|
@@ -107,13 +107,13 @@ async function createReadme(scriptName: string) {
|
|
|
107
107
|
|
|
108
108
|
await writeFile(
|
|
109
109
|
filePath,
|
|
110
|
-
`# ${scriptName} - A Scripting
|
|
110
|
+
`# ${scriptName} - A script for Scripting app.
|
|
111
111
|
|
|
112
112
|
## Start dev server
|
|
113
113
|
|
|
114
|
-
\`npm
|
|
114
|
+
\`npm start\`
|
|
115
115
|
|
|
116
|
-
## Build
|
|
116
|
+
## Build Script
|
|
117
117
|
|
|
118
118
|
\`npm run build\`
|
|
119
119
|
`,
|
|
@@ -146,19 +146,20 @@ async function createTSConfig(scriptName: string) {
|
|
|
146
146
|
"forceConsistentCasingInFileNames": true,
|
|
147
147
|
"noFallthroughCasesInSwitch": true,
|
|
148
148
|
"module": "CommonJS",
|
|
149
|
+
"resolveJsonModule": true,
|
|
149
150
|
"skipLibCheck": true,
|
|
150
151
|
"jsx": "react",
|
|
151
152
|
"jsxFactory": "createElement",
|
|
152
|
-
"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// ]
|
|
158
|
-
// }
|
|
153
|
+
"paths": {
|
|
154
|
+
"scripting": [
|
|
155
|
+
"./types/scripting.d.ts"
|
|
156
|
+
]
|
|
157
|
+
}
|
|
159
158
|
},
|
|
160
159
|
"include": [
|
|
161
|
-
"src"
|
|
160
|
+
"src",
|
|
161
|
+
"types/assets.d.ts",
|
|
162
|
+
"types/global.d.ts",
|
|
162
163
|
],
|
|
163
164
|
}`,
|
|
164
165
|
'utf-8'
|
|
@@ -169,7 +170,7 @@ async function createTSConfig(scriptName: string) {
|
|
|
169
170
|
)
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
async function
|
|
173
|
+
async function copyDtsAsset(scriptName: string, fileName: string) {
|
|
173
174
|
console.log(` > Creating ${scriptName}/types/${fileName}.d.ts ...`)
|
|
174
175
|
await copyFile(
|
|
175
176
|
path.join(__dirname, `../public/${fileName}.d.ts`),
|
|
@@ -181,9 +182,9 @@ async function copyAsset(scriptName: string, fileName: string) {
|
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
async function copyAssets(scriptName: string) {
|
|
184
|
-
await
|
|
185
|
-
await
|
|
186
|
-
await
|
|
185
|
+
await copyDtsAsset(scriptName, 'scripting')
|
|
186
|
+
await copyDtsAsset(scriptName, 'global')
|
|
187
|
+
await copyDtsAsset(scriptName, 'assets')
|
|
187
188
|
|
|
188
189
|
// console.log(` > Creating ${scriptName}/src/svgs/logo.svg ...`)
|
|
189
190
|
// await copyFile(
|
|
@@ -244,7 +245,7 @@ export async function createScript(scriptName: string) {
|
|
|
244
245
|
|
|
245
246
|
console.log(
|
|
246
247
|
`All done! Run ${chalk.bold(
|
|
247
|
-
chalk.green(`cd ${scriptName} && npm
|
|
248
|
+
chalk.green(`cd ${scriptName} && npm start`)
|
|
248
249
|
)} to start the dev server.`
|
|
249
250
|
)
|
|
250
251
|
|