create-widget 0.0.2 → 0.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.
- package/package.json +5 -1
- package/.editorconfig +0 -13
- package/.idea/create-widget.iml +0 -9
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jpa-buddy.xml +0 -6
- package/.idea/misc.xml +0 -8
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/src/index.ts +0 -144
- package/src/utils/FileUtils.ts +0 -33
- package/src/utils/deepMerge.ts +0 -26
- package/src/utils/directoryTraverse.ts +0 -35
- package/src/utils/getCommand.ts +0 -13
- package/src/utils/renderTemplate.ts +0 -88
- package/src/utils/sortDependencies.ts +0 -22
- package/test/index.test.ts +0 -24
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -6
- package/widget-test/.vscode/extensions.json +0 -3
- package/widget-test/README.md +0 -40
- package/widget-test/env.d.ts +0 -1
- package/widget-test/index.html +0 -13
- package/widget-test/package.json +0 -30
- package/widget-test/public/favicon.ico +0 -0
- package/widget-test/public/preview_clock.png +0 -0
- package/widget-test/public/widget.json +0 -50
- package/widget-test/src/App.vue +0 -9
- package/widget-test/src/assets/main.css +0 -3
- package/widget-test/src/main.ts +0 -12
- package/widget-test/src/router/index.ts +0 -11
- package/widget-test/src/widgets/clock/Clock.widget.ts +0 -32
- package/widget-test/src/widgets/clock/ClockConfigView.vue +0 -38
- package/widget-test/src/widgets/clock/ClockWidgetRoutes.ts +0 -28
- package/widget-test/src/widgets/clock/ClockWidgetView.vue +0 -34
- package/widget-test/src/widgets/clock/model/ClockModel.ts +0 -5
- package/widget-test/src/widgets/widget-router.ts +0 -8
- package/widget-test/tsconfig.app.json +0 -13
- package/widget-test/tsconfig.json +0 -11
- package/widget-test/tsconfig.node.json +0 -17
- package/widget-test/vite.config.ts +0 -14
- package/widget-test/widget.package.ts +0 -20
- package/widget-test/yarn.lock +0 -1399
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-widget",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "Neo Fu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"bin": {
|
|
9
9
|
"create-widget": "lib/index.js"
|
|
10
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"lib/index.js",
|
|
13
|
+
"template"
|
|
14
|
+
],
|
|
11
15
|
"type": "module",
|
|
12
16
|
"publishConfig": {
|
|
13
17
|
"access": "public"
|
package/.editorconfig
DELETED
package/.idea/create-widget.iml
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|
package/.idea/jpa-buddy.xml
DELETED
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/create-widget.iml" filepath="$PROJECT_DIR$/.idea/create-widget.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
package/.idea/prettier.xml
DELETED
package/.idea/vcs.xml
DELETED
package/src/index.ts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import * as process from 'process'
|
|
3
|
-
import gradient from 'gradient-string'
|
|
4
|
-
import prompts from 'prompts'
|
|
5
|
-
import minimist from 'minimist'
|
|
6
|
-
import chalk from 'chalk'
|
|
7
|
-
import path from 'path'
|
|
8
|
-
import {postOrderDirectoryTraverse} from './utils/directoryTraverse'
|
|
9
|
-
import getCommand from './utils/getCommand'
|
|
10
|
-
import {fileURLToPath} from 'url'
|
|
11
|
-
import {FileUtils} from "./utils/FileUtils";
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
14
|
-
const __dirname = path.dirname(__filename)
|
|
15
|
-
|
|
16
|
-
function canSkipEmptying(dir: string) {
|
|
17
|
-
if (!fs.existsSync(dir)) {
|
|
18
|
-
return true
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const files = fs.readdirSync(dir)
|
|
22
|
-
if (files.length === 0) {
|
|
23
|
-
return true
|
|
24
|
-
}
|
|
25
|
-
if (files.length === 1 && files[0] === '.git') {
|
|
26
|
-
return true
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function emptyDir(dir) {
|
|
33
|
-
if (!fs.existsSync(dir)) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
postOrderDirectoryTraverse(
|
|
38
|
-
dir,
|
|
39
|
-
dir => fs.rmdirSync(dir),
|
|
40
|
-
file => fs.unlinkSync(file),
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function init() {
|
|
45
|
-
console.log()
|
|
46
|
-
let defaultBanner = 'Widget.js - The Desktop Widget Framework'
|
|
47
|
-
const gradientBanner = gradient([
|
|
48
|
-
{color: '#42d392', pos: 0},
|
|
49
|
-
{color: '#42d392', pos: 0.1},
|
|
50
|
-
{color: '#647eff', pos: 1},
|
|
51
|
-
])(defaultBanner)
|
|
52
|
-
console.log(process.stdout.isTTY && process.stdout.getColorDepth() > 8 ? gradientBanner : defaultBanner)
|
|
53
|
-
console.log()
|
|
54
|
-
const argv = minimist(process.argv.slice(2), {
|
|
55
|
-
alias: {
|
|
56
|
-
typescript: ['ts'],
|
|
57
|
-
'with-tests': ['tests'],
|
|
58
|
-
router: ['vue-router'],
|
|
59
|
-
},
|
|
60
|
-
string: ['_'],
|
|
61
|
-
// all arguments are treated as booleans
|
|
62
|
-
boolean: true,
|
|
63
|
-
})
|
|
64
|
-
let targetDir = argv._[0]
|
|
65
|
-
const defaultProjectName = !targetDir ? 'widget-project' : targetDir
|
|
66
|
-
const forceOverwrite = argv.force
|
|
67
|
-
|
|
68
|
-
const cwd = process.cwd()
|
|
69
|
-
let result: {
|
|
70
|
-
projectName?: string
|
|
71
|
-
shouldOverwrite?: boolean
|
|
72
|
-
} = {}
|
|
73
|
-
result = await prompts(
|
|
74
|
-
[
|
|
75
|
-
{
|
|
76
|
-
name: 'projectName',
|
|
77
|
-
type: targetDir ? null : 'text',
|
|
78
|
-
message: 'Project name:',
|
|
79
|
-
initial: defaultProjectName,
|
|
80
|
-
onState: state => (targetDir = String(state.value).trim() || defaultProjectName),
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: 'shouldOverwrite',
|
|
84
|
-
type: () => (canSkipEmptying(targetDir) || forceOverwrite ? null : 'confirm'),
|
|
85
|
-
message: () => {
|
|
86
|
-
const dirForPrompt = targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`
|
|
87
|
-
return `${dirForPrompt} is not empty. Remove existing files and continue?`
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
{
|
|
92
|
-
onCancel: () => {
|
|
93
|
-
throw new Error(chalk.red('✖') + ' Operation cancelled')
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
// `initial` won't take effect if the prompt type is null
|
|
99
|
-
// so we still have to assign the default values here
|
|
100
|
-
const {projectName, shouldOverwrite = argv.force} = result
|
|
101
|
-
|
|
102
|
-
const root = path.join(cwd, targetDir)
|
|
103
|
-
|
|
104
|
-
if (fs.existsSync(root) && shouldOverwrite) {
|
|
105
|
-
emptyDir(root)
|
|
106
|
-
} else if (!fs.existsSync(root)) {
|
|
107
|
-
fs.mkdirSync(root)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
console.log(`\nScaffolding project in ${root}...`)
|
|
111
|
-
|
|
112
|
-
const templateRoot = path.join(__dirname, '../template')
|
|
113
|
-
|
|
114
|
-
//复制templateRoot下的文件到root目录下
|
|
115
|
-
await FileUtils.copyFolderRecursive(templateRoot, root)
|
|
116
|
-
|
|
117
|
-
// const callbacks = []
|
|
118
|
-
//
|
|
119
|
-
// const render = function render(templateName) {
|
|
120
|
-
// const templateDir = path.resolve(templateRoot, templateName)
|
|
121
|
-
// renderTemplate(templateDir, root, callbacks)
|
|
122
|
-
// }
|
|
123
|
-
// // 将template里的文件都复制到 root目录下
|
|
124
|
-
// const templateFiles = fs.readdirSync(templateRoot)
|
|
125
|
-
// for (const file of templateFiles) {
|
|
126
|
-
// render(file)
|
|
127
|
-
// }
|
|
128
|
-
|
|
129
|
-
// Instructions:
|
|
130
|
-
// Supported package managers: pnpm > yarn > npm
|
|
131
|
-
const userAgent = process.env.npm_config_user_agent ?? ''
|
|
132
|
-
const packageManager = /pnpm/.test(userAgent) ? 'pnpm' : /yarn/.test(userAgent) ? 'yarn' : 'npm'
|
|
133
|
-
|
|
134
|
-
console.log(`\nDone. Now run:\n`)
|
|
135
|
-
if (root !== cwd) {
|
|
136
|
-
const cdProjectName = path.relative(cwd, root)
|
|
137
|
-
console.log(` ${chalk.bold(chalk.green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}`)
|
|
138
|
-
}
|
|
139
|
-
console.log(` ${chalk.bold(chalk.green(getCommand(packageManager, 'install')))}`)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
init().catch(e => {
|
|
143
|
-
console.error(e)
|
|
144
|
-
})
|
package/src/utils/FileUtils.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs'
|
|
2
|
-
import {copy,ensureDir} from "fs-extra";
|
|
3
|
-
|
|
4
|
-
export class FileUtils {
|
|
5
|
-
static async copyFolderRecursive(src: string, dest: string): Promise<void> {
|
|
6
|
-
try {
|
|
7
|
-
// 创建目标文件夹
|
|
8
|
-
await ensureDir(dest)
|
|
9
|
-
|
|
10
|
-
// 获取源文件夹中的所有文件和子文件夹
|
|
11
|
-
const items = await fs.promises.readdir(src)
|
|
12
|
-
|
|
13
|
-
// 遍历每一个文件或子文件夹
|
|
14
|
-
for (const item of items) {
|
|
15
|
-
const srcPath = `${src}/${item}`
|
|
16
|
-
const destPath = `${dest}/${item}`
|
|
17
|
-
|
|
18
|
-
// 检查当前项目是文件还是文件夹
|
|
19
|
-
const stats = await fs.promises.stat(srcPath)
|
|
20
|
-
|
|
21
|
-
if (stats.isDirectory()) {
|
|
22
|
-
// 如果是文件夹,递归复制
|
|
23
|
-
await this.copyFolderRecursive(srcPath, destPath)
|
|
24
|
-
} else {
|
|
25
|
-
// 如果是文件,直接复制
|
|
26
|
-
await copy(srcPath, destPath)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(`Error copying folder: ${error.message}`)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
package/src/utils/deepMerge.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const isObject = (val) => val && typeof val === 'object'
|
|
2
|
-
const mergeArrayWithDedupe = (a, b) => Array.from(new Set([...a, ...b]))
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Recursively merge the content of the new object to the existing one
|
|
6
|
-
* @param {Object} target the existing object
|
|
7
|
-
* @param {Object} obj the new object
|
|
8
|
-
*/
|
|
9
|
-
function deepMerge(target, obj) {
|
|
10
|
-
for (const key of Object.keys(obj)) {
|
|
11
|
-
const oldVal = target[key]
|
|
12
|
-
const newVal = obj[key]
|
|
13
|
-
|
|
14
|
-
if (Array.isArray(oldVal) && Array.isArray(newVal)) {
|
|
15
|
-
target[key] = mergeArrayWithDedupe(oldVal, newVal)
|
|
16
|
-
} else if (isObject(oldVal) && isObject(newVal)) {
|
|
17
|
-
target[key] = deepMerge(oldVal, newVal)
|
|
18
|
-
} else {
|
|
19
|
-
target[key] = newVal
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return target
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default deepMerge
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs'
|
|
2
|
-
import * as path from 'node:path'
|
|
3
|
-
|
|
4
|
-
export function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
5
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
6
|
-
if (filename === '.git') {
|
|
7
|
-
continue
|
|
8
|
-
}
|
|
9
|
-
const fullpath = path.resolve(dir, filename)
|
|
10
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
11
|
-
dirCallback(fullpath)
|
|
12
|
-
// in case the dirCallback removes the directory entirely
|
|
13
|
-
if (fs.existsSync(fullpath)) {
|
|
14
|
-
preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback)
|
|
15
|
-
}
|
|
16
|
-
continue
|
|
17
|
-
}
|
|
18
|
-
fileCallback(fullpath)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
23
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
24
|
-
if (filename === '.git') {
|
|
25
|
-
continue
|
|
26
|
-
}
|
|
27
|
-
const fullpath = path.resolve(dir, filename)
|
|
28
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
29
|
-
postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback)
|
|
30
|
-
dirCallback(fullpath)
|
|
31
|
-
continue
|
|
32
|
-
}
|
|
33
|
-
fileCallback(fullpath)
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/utils/getCommand.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default function getCommand(packageManager: string, scriptName: string, args?: string) {
|
|
2
|
-
if (scriptName === 'install') {
|
|
3
|
-
return packageManager === 'yarn' ? 'yarn' : `${packageManager} install`
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
if (args) {
|
|
7
|
-
return packageManager === 'npm'
|
|
8
|
-
? `npm run ${scriptName} -- ${args}`
|
|
9
|
-
: `${packageManager} ${scriptName} ${args}`
|
|
10
|
-
} else {
|
|
11
|
-
return packageManager === 'npm' ? `npm run ${scriptName}` : `${packageManager} ${scriptName}`
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs'
|
|
2
|
-
import * as path from 'node:path'
|
|
3
|
-
import { pathToFileURL } from 'node:url'
|
|
4
|
-
|
|
5
|
-
import deepMerge from './deepMerge'
|
|
6
|
-
import sortDependencies from './sortDependencies'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Renders a template folder/file to the file system,
|
|
10
|
-
* by recursively copying all files under the `src` directory,
|
|
11
|
-
* with the following exception:
|
|
12
|
-
* - `_filename` should be renamed to `.filename`
|
|
13
|
-
* - Fields in `package.json` should be recursively merged
|
|
14
|
-
* @param {string} src source filename to copy
|
|
15
|
-
* @param {string} dest destination filename of the copy operation
|
|
16
|
-
*/
|
|
17
|
-
function renderTemplate(src, dest, callbacks) {
|
|
18
|
-
const stats = fs.statSync(src)
|
|
19
|
-
|
|
20
|
-
if (stats.isDirectory()) {
|
|
21
|
-
// skip node_module
|
|
22
|
-
if (path.basename(src) === 'node_modules') {
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// if it's a directory, render its subdirectories and files recursively
|
|
27
|
-
fs.mkdirSync(dest, { recursive: true })
|
|
28
|
-
for (const file of fs.readdirSync(src)) {
|
|
29
|
-
renderTemplate(path.resolve(src, file), path.resolve(dest, file), callbacks)
|
|
30
|
-
}
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const filename = path.basename(src)
|
|
35
|
-
|
|
36
|
-
if (filename === 'package.json' && fs.existsSync(dest)) {
|
|
37
|
-
// merge instead of overwriting
|
|
38
|
-
const existing = JSON.parse(fs.readFileSync(dest, 'utf8'))
|
|
39
|
-
const newPackage = JSON.parse(fs.readFileSync(src, 'utf8'))
|
|
40
|
-
const pkg = sortDependencies(deepMerge(existing, newPackage))
|
|
41
|
-
fs.writeFileSync(dest, JSON.stringify(pkg, null, 2) + '\n')
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (filename === 'extensions.json' && fs.existsSync(dest)) {
|
|
46
|
-
// merge instead of overwriting
|
|
47
|
-
const existing = JSON.parse(fs.readFileSync(dest, 'utf8'))
|
|
48
|
-
const newExtensions = JSON.parse(fs.readFileSync(src, 'utf8'))
|
|
49
|
-
const extensions = deepMerge(existing, newExtensions)
|
|
50
|
-
fs.writeFileSync(dest, JSON.stringify(extensions, null, 2) + '\n')
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (filename.startsWith('_')) {
|
|
55
|
-
// rename `_file` to `.file`
|
|
56
|
-
dest = path.resolve(path.dirname(dest), filename.replace(/^_/, '.'))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (filename === '_gitignore' && fs.existsSync(dest)) {
|
|
60
|
-
// append to existing .gitignore
|
|
61
|
-
const existing = fs.readFileSync(dest, 'utf8')
|
|
62
|
-
const newGitignore = fs.readFileSync(src, 'utf8')
|
|
63
|
-
fs.writeFileSync(dest, existing + '\n' + newGitignore)
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// data file for EJS templates
|
|
68
|
-
if (filename.endsWith('.data.mjs')) {
|
|
69
|
-
// use dest path as key for the data store
|
|
70
|
-
dest = dest.replace(/\.data\.mjs$/, '')
|
|
71
|
-
|
|
72
|
-
// Add a callback to the array for late usage when template files are being processed
|
|
73
|
-
callbacks.push(async (dataStore) => {
|
|
74
|
-
const getData = (await import(pathToFileURL(src).toString())).default
|
|
75
|
-
|
|
76
|
-
// Though current `getData` are all sync, we still retain the possibility of async
|
|
77
|
-
dataStore[dest] = await getData({
|
|
78
|
-
oldData: dataStore[dest] || {}
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
return // skip copying the data file
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
fs.copyFileSync(src, dest)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default renderTemplate
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default function sortDependencies(packageJson) {
|
|
2
|
-
const sorted = {}
|
|
3
|
-
|
|
4
|
-
const depTypes = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
|
|
5
|
-
|
|
6
|
-
for (const depType of depTypes) {
|
|
7
|
-
if (packageJson[depType]) {
|
|
8
|
-
sorted[depType] = {}
|
|
9
|
-
|
|
10
|
-
Object.keys(packageJson[depType])
|
|
11
|
-
.sort()
|
|
12
|
-
.forEach((name) => {
|
|
13
|
-
sorted[depType][name] = packageJson[depType][name]
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
...packageJson,
|
|
20
|
-
...sorted
|
|
21
|
-
}
|
|
22
|
-
}
|
package/test/index.test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {expect, test} from "vitest";
|
|
2
|
-
import {minimatch} from "minimatch";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import gradient from "gradient-string"
|
|
5
|
-
|
|
6
|
-
test('minimatch',()=>{
|
|
7
|
-
let fileName = path.basename('C:\\Users\\rtuge\\Desktop\\github\\widgetjs\\packages\\@widget-js\\cli\\template\\Widget.ejs');
|
|
8
|
-
expect(minimatch(fileName,'*.ejs')).toBeTruthy()
|
|
9
|
-
expect(minimatch(fileName,'*.ts')).toBeFalsy()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
test('gradient brand',()=>{
|
|
14
|
-
console.log(gradient([
|
|
15
|
-
{ color: '#42d392', pos: 0 },
|
|
16
|
-
{ color: '#42d392', pos: 0.1 },
|
|
17
|
-
{ color: '#647eff', pos: 1 }
|
|
18
|
-
])('Widget.js - The Desktop Widget Framework'))
|
|
19
|
-
console.log(gradient([
|
|
20
|
-
{color: '#42d392', pos: 0},
|
|
21
|
-
{color: '#42d392', pos: 0.1},
|
|
22
|
-
{color: '#647eff', pos: 1}
|
|
23
|
-
])('Widget.js - The Desktop Widget Framework'));
|
|
24
|
-
})
|
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
package/widget-test/README.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# hello widget
|
|
2
|
-
|
|
3
|
-
This template should help get you started developing with Vue 3 in Vite.
|
|
4
|
-
|
|
5
|
-
## Recommended IDE Setup
|
|
6
|
-
|
|
7
|
-
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
|
8
|
-
|
|
9
|
-
## Type Support for `.vue` Imports in TS
|
|
10
|
-
|
|
11
|
-
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
|
12
|
-
|
|
13
|
-
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
|
14
|
-
|
|
15
|
-
1. Disable the built-in TypeScript Extension
|
|
16
|
-
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
|
17
|
-
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
|
18
|
-
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
|
19
|
-
|
|
20
|
-
## Customize configuration
|
|
21
|
-
|
|
22
|
-
See [Vite Configuration Reference](https://vitejs.dev/config/).
|
|
23
|
-
|
|
24
|
-
## Project Setup
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
npm install
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Compile and Hot-Reload for Development
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
npm run dev
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Type-Check, Compile and Minify for Production
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
npm run build
|
|
40
|
-
```
|
package/widget-test/env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/widget-test/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<link rel="icon" href="/favicon.ico">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/src/main.ts"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/widget-test/package.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hello-widget",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "run-p type-check \"build-only {@}\" --",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"build-only": "vite build",
|
|
11
|
-
"type-check": "vue-tsc --build --force"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"vue": "^3.3.11",
|
|
15
|
-
"vue-router": "^4.2.5",
|
|
16
|
-
"@widget-js/core": "0.11.20",
|
|
17
|
-
"@widget-js/vue3": "0.11.21-rc.2"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@tsconfig/node18": "^18.2.2",
|
|
21
|
-
"@types/node": "^18.19.3",
|
|
22
|
-
"@vitejs/plugin-vue": "^4.5.2",
|
|
23
|
-
"@vue/tsconfig": "^0.5.0",
|
|
24
|
-
"npm-run-all2": "^6.1.1",
|
|
25
|
-
"typescript": "~5.3.0",
|
|
26
|
-
"vite": "^5.0.10",
|
|
27
|
-
"vue-tsc": "^1.8.25",
|
|
28
|
-
"@widget-js/vite-plugin-widget": "^1.2.8"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cn.example.widget",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"author": "修改成你的信息",
|
|
5
|
-
"homepage": "",
|
|
6
|
-
"title": {
|
|
7
|
-
"zh-CN": "修改成你的组件标题"
|
|
8
|
-
},
|
|
9
|
-
"description": {
|
|
10
|
-
"zh-CN": "修改成你的组件描述"
|
|
11
|
-
},
|
|
12
|
-
"entry": "/",
|
|
13
|
-
"hash": true,
|
|
14
|
-
"url": "",
|
|
15
|
-
"widgets": [
|
|
16
|
-
{
|
|
17
|
-
"name": "cn.test.widget.clock",
|
|
18
|
-
"title": {
|
|
19
|
-
"zh-CN": "时钟"
|
|
20
|
-
},
|
|
21
|
-
"description": {
|
|
22
|
-
"zh-CN": "Hello world!"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"recommend"
|
|
26
|
-
],
|
|
27
|
-
"security": false,
|
|
28
|
-
"permissions": [],
|
|
29
|
-
"lang": "zh-CN",
|
|
30
|
-
"width": 2,
|
|
31
|
-
"height": 2,
|
|
32
|
-
"maxWidth": 6,
|
|
33
|
-
"webviewTag": false,
|
|
34
|
-
"maxHeight": 6,
|
|
35
|
-
"minWidth": 2,
|
|
36
|
-
"minHeight": 2,
|
|
37
|
-
"movable": true,
|
|
38
|
-
"singleton": false,
|
|
39
|
-
"resizable": true,
|
|
40
|
-
"path": "/widget/clock",
|
|
41
|
-
"meta": {},
|
|
42
|
-
"backgroundThrottling": true,
|
|
43
|
-
"previewImage": "/preview_clock.png",
|
|
44
|
-
"supportDeployMode": 17,
|
|
45
|
-
"configPagePath": "/widget/config/clock",
|
|
46
|
-
"routes": []
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
"pages": []
|
|
50
|
-
}
|