@widget-js/cli 1.2.11 → 24.1.1-beta.10
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/.idea/codeStyles/Project.xml +60 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +5 -7
- package/jest.config.js +3 -3
- package/lib/{chunk-RAXJBANW.js → chunk-I4ZBPB2S.js} +6 -6
- package/lib/{chunk-IJH6LXRT.js → chunk-RDJH7Z4C.js} +5 -5
- package/lib/{chunk-3GPAHQ6O.js → chunk-XPJ33Y5L.js} +2 -2
- package/lib/{createWidget-UFW26NP6.js → createWidget-4LQ6PVEM.js} +16 -16
- package/lib/{dependencies-MRJDJJ6Q.js → dependencies-AVNHKRF3.js} +18 -18
- package/lib/index.js +13 -8
- package/lib/{init-MQONV3N3.js → init-HCEGKTNF.js} +15 -15
- package/lib/publish-C52GHJWG.js +50 -0
- package/lib/{release-XUYU5WNC.js → release-5GS34BAJ.js} +52 -48
- package/package.json +29 -18
- package/src/build/build.ts +8 -8
- package/src/createWidget.ts +232 -226
- package/src/dependencies/index.ts +6 -5
- package/src/dependencies/localDependencies.ts +17 -18
- package/src/dependencies/remoteDependencies.ts +22 -25
- package/src/index.ts +47 -38
- package/src/init/init.ts +121 -119
- package/src/promts/promptChecker.ts +10 -8
- package/src/publish/index.ts +60 -0
- package/src/release/ftp.ts +31 -27
- package/src/release/oss.ts +41 -38
- package/src/release/release.ts +17 -24
- package/src/release/update-zip.ts +18 -14
- package/src/utils/EJSUtils.ts +18 -17
- package/src/utils/PrettierUtils.ts +12 -11
- package/src/utils/WidgetPackageUtils.ts +13 -13
- package/src/utils.ts +31 -27
- package/template/WidgetConfig.ejs +7 -6
- package/template/WidgetDefine.ejs +6 -18
- package/template/widget-router.ts +4 -3
- package/test/index.test.ts +7 -7
- package/tsconfig.json +25 -25
- package/tsup.config.ts +4 -4
- package/vite.config.ts +15 -15
- package/.editorconfig +0 -16
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jpa-buddy.xml +0 -6
- package/.idea/prettier.xml +0 -6
- package/release-xyy.json +0 -7
package/src/release/oss.ts
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import chalk from
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import OSS from 'ali-oss'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
import consola from 'consola'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
export const AccessKeyID = packageData.oss?.id ??
|
|
7
|
-
export const AccessKeySecret = packageData.oss?.secret ??
|
|
6
|
+
const packageData = JSON.parse(fs.readFileSync('./package.json').toString())
|
|
7
|
+
export const AccessKeyID = packageData.oss?.id ?? 'default'
|
|
8
|
+
export const AccessKeySecret = packageData.oss?.secret ?? 'default'
|
|
8
9
|
|
|
9
10
|
const headers = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
11
|
+
// 指定Object的存储类型。
|
|
12
|
+
'x-oss-storage-class': 'Standard',
|
|
13
|
+
// 指定Object的访问权限。
|
|
14
|
+
'x-oss-object-acl': 'public-read',
|
|
15
|
+
'x-oss-forbid-overwrite': 'false',
|
|
16
|
+
'Cache-Control': 'no-cache',
|
|
17
|
+
}
|
|
17
18
|
|
|
18
19
|
const clinet = new OSS({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
20
|
+
// yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
|
|
21
|
+
region: 'oss-cn-hangzhou',
|
|
22
|
+
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
|
23
|
+
accessKeyId: AccessKeyID,
|
|
24
|
+
accessKeySecret: AccessKeySecret,
|
|
25
|
+
bucket: 'widget-fun',
|
|
26
|
+
})
|
|
26
27
|
|
|
27
|
-
export async function put(ossPath:string, file:any) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export async function put(ossPath: string, file: any) {
|
|
29
|
+
try {
|
|
30
|
+
// 填写OSS文件完整路径和本地文件的完整路径。OSS文件完整路径中不能包含Bucket名称。
|
|
31
|
+
// 如果本地文件的完整路径中未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
|
|
32
|
+
await clinet.put(ossPath, file, { headers })
|
|
33
|
+
consola.log(chalk.green(`上传成功:${file}->${ossPath}`))
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
consola.log(e)
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export async function copy(dist:string, src:string) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
export async function copy(dist: string, src: string) {
|
|
41
|
+
try {
|
|
42
|
+
// 填写OSS文件完整路径和本地文件的完整路径。OSS文件完整路径中不能包含Bucket名称。
|
|
43
|
+
// 如果本地文件的完整路径中未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
|
|
44
|
+
await clinet.copy(dist, src, { headers })
|
|
45
|
+
consola.log(chalk.green(`复制成功:${src}->${dist}`))
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
console.error(e)
|
|
49
|
+
}
|
|
47
50
|
}
|
package/src/release/release.ts
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { Buffer } from 'node:buffer'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
import consola from 'consola'
|
|
3
6
|
import promptChecker from '../promts/promptChecker.js'
|
|
4
7
|
import zipDirectory from './update-zip.js'
|
|
5
|
-
import {copy, put} from './oss.js'
|
|
6
|
-
import
|
|
7
|
-
import {ftpUpload} from './ftp'
|
|
8
|
-
|
|
9
|
-
async function delay(time: number) {
|
|
10
|
-
return new Promise<void>((resolve, reject) => {
|
|
11
|
-
setTimeout(() => {
|
|
12
|
-
resolve()
|
|
13
|
-
}, time)
|
|
14
|
-
})
|
|
15
|
-
}
|
|
8
|
+
import { copy, put } from './oss.js'
|
|
9
|
+
import { ftpUpload } from './ftp'
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
async function release(options: any) {
|
|
18
12
|
if (options.type == 'ftp') {
|
|
19
13
|
await ftpUpload(options.file)
|
|
20
14
|
return
|
|
21
15
|
}
|
|
22
16
|
const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
|
|
23
17
|
const changelogJSON = JSON.parse(fs.readFileSync('changelog.json', 'utf-8'))
|
|
24
|
-
const version = packageJSON
|
|
18
|
+
const version = packageJSON.version
|
|
25
19
|
const changelog = changelogJSON[version]
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
const needUpdateElectron = await promptChecker({
|
|
28
22
|
type: 'confirm',
|
|
29
23
|
name: 'electron',
|
|
30
24
|
message: chalk.blue('用户是否需要更新Electron?'),
|
|
@@ -37,7 +31,7 @@ const release = async (options: any) => {
|
|
|
37
31
|
// });
|
|
38
32
|
|
|
39
33
|
const versionInfo = {
|
|
40
|
-
version
|
|
34
|
+
version,
|
|
41
35
|
releaseNote: changelog,
|
|
42
36
|
updateElectron: needUpdateElectron,
|
|
43
37
|
updateNodeModule: false,
|
|
@@ -54,24 +48,23 @@ const release = async (options: any) => {
|
|
|
54
48
|
}
|
|
55
49
|
const updateZipPath = path.join(`./dist/update.zip`)
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
consola.log(chalk.blue('压缩更新文件中'))
|
|
58
52
|
await zipDirectory('./release', updateZipPath)
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
consola.log(chalk.blue('上传installer.exe到OSS'))
|
|
61
55
|
await put('version/installer.exe', installerPath)
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
consola.log(chalk.blue('上传update.zip到OSS'))
|
|
64
58
|
await put('version/update.zip', updateZipPath)
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
consola.log(chalk.blue('更新版本信息'))
|
|
67
61
|
versionInfo.downloadLink = 'https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip'
|
|
68
62
|
const versionJSON = JSON.stringify(versionInfo, null, 2)
|
|
69
63
|
await put('version/version.json', Buffer.from(versionJSON))
|
|
70
64
|
|
|
71
|
-
copy(`version/history/${version}.exe`, 'version/installer.exe')
|
|
72
|
-
copy(`version/history/update-${version}.zip`, 'version/update.zip')
|
|
65
|
+
await Promise.all([copy(`version/history/${version}.exe`, 'version/installer.exe'), copy(`version/history/update-${version}.zip`, 'version/update.zip')])
|
|
73
66
|
|
|
74
|
-
|
|
67
|
+
consola.log(chalk.yellow(versionJSON))
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
export default release
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import archiver from
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import archiver from 'archiver'
|
|
3
3
|
|
|
4
|
-
function zipDirectory(sourceDir:string, outPath:string, ignoreDir?:string[]) {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function zipDirectory(sourceDir: string, outPath: string, ignoreDir?: string[]) {
|
|
5
|
+
const archive = archiver('zip', { zlib: { level: 9 } })
|
|
6
|
+
const stream = fs.createWriteStream(outPath)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
return new Promise<void>((resolve, reject) => {
|
|
9
|
+
const ignore: string[] = ['node_modules/**']
|
|
10
|
+
if (ignoreDir) {
|
|
11
|
+
ignore.push(...ignoreDir)
|
|
12
|
+
}
|
|
13
|
+
archive
|
|
14
|
+
.glob('**/*', { cwd: sourceDir, ignore })
|
|
15
|
+
.on('error', err => reject(err))
|
|
16
|
+
.pipe(stream)
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
stream.on('close', () => resolve())
|
|
19
|
+
archive.finalize()
|
|
20
|
+
})
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
export default zipDirectory
|
|
23
|
+
export default zipDirectory
|
package/src/utils/EJSUtils.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import type { Data } from 'ejs'
|
|
4
|
+
import ejs from 'ejs'
|
|
5
|
+
import type { BuiltInParserName } from 'prettier'
|
|
6
|
+
import { dirname } from 'dirname-filename-esm'
|
|
7
|
+
import { PrettierUtils } from './PrettierUtils'
|
|
8
|
+
|
|
9
|
+
export class EJSUtils {
|
|
10
|
+
static async renderToFile(templateFile: string, outputFile: string, parser: BuiltInParserName, renderOptions: Data) {
|
|
11
|
+
const defineTemplatePath = path.join(dirname(import.meta), '../template', templateFile)
|
|
12
|
+
const defineTemplate = fs.readFileSync(defineTemplatePath, 'utf8')
|
|
13
|
+
// Format the EJS code using Prettier
|
|
14
|
+
const code = ejs.render(defineTemplate, renderOptions)
|
|
15
|
+
const formattedEJSCode = await PrettierUtils.format(code, parser)
|
|
16
|
+
fs.writeFileSync(outputFile, formattedEJSCode)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {BuiltInParserName
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
1
|
+
import type { BuiltInParserName } from 'prettier'
|
|
2
|
+
import { format } from 'prettier'
|
|
3
|
+
|
|
4
|
+
export class PrettierUtils {
|
|
5
|
+
static async format(code: string, parser: BuiltInParserName) {
|
|
6
|
+
return format(code, {
|
|
7
|
+
parser,
|
|
8
|
+
tabWidth: 2,
|
|
9
|
+
singleQuote: true,
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export class WidgetPackageUtils {
|
|
6
|
-
static getRootDir(widgetPackage: WidgetPackage) {
|
|
7
|
-
const widgetRootDir = path.join(process.cwd(), widgetPackage.devOptions?.folder ?? './src/widgets')
|
|
8
|
-
if (!fs.existsSync(widgetRootDir)) {
|
|
9
|
-
fs.mkdirSync(widgetRootDir, {recursive: true})
|
|
10
|
-
}
|
|
11
|
-
return widgetRootDir
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import type { WidgetPackage } from '@widget-js/core'
|
|
4
|
+
|
|
5
|
+
export class WidgetPackageUtils {
|
|
6
|
+
static getRootDir(widgetPackage: WidgetPackage) {
|
|
7
|
+
const widgetRootDir = path.join(process.cwd(), widgetPackage.devOptions?.folder ?? './src/widgets')
|
|
8
|
+
if (!fs.existsSync(widgetRootDir)) {
|
|
9
|
+
fs.mkdirSync(widgetRootDir, { recursive: true })
|
|
10
|
+
}
|
|
11
|
+
return widgetRootDir
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import process from
|
|
3
|
-
import fs from
|
|
4
|
-
import packageJson from
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import packageJson from 'package-json'
|
|
5
5
|
|
|
6
6
|
export const widgetPackages: { [key: string]: string } = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
'@widget-js/core': '',
|
|
8
|
+
'@widget-js/vue3': '',
|
|
9
|
+
'@widget-js/cli': '',
|
|
10
|
+
'@widget-js/utils': '',
|
|
11
|
+
'@widget-js/vite-plugin-widget': '',
|
|
12
|
+
}
|
|
9
13
|
export default function exit(code: number = 0) {
|
|
10
14
|
if (exports.exitProcess) {
|
|
11
|
-
process.exit(code)
|
|
12
|
-
}
|
|
13
|
-
|
|
15
|
+
process.exit(code)
|
|
16
|
+
}
|
|
17
|
+
else if (code > 0) {
|
|
18
|
+
throw new Error(`Process exited with code ${code}`)
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export function getPackagePath() {
|
|
18
|
-
return path.join(process.cwd(),
|
|
23
|
+
return path.join(process.cwd(), 'package.json')
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
|
|
22
26
|
export class Utils {
|
|
23
27
|
static async getRemoteVersion(packageName: string): Promise<string> {
|
|
24
|
-
const metadata = await packageJson(packageName)
|
|
25
|
-
|
|
26
|
-
return version as string
|
|
28
|
+
const metadata = await packageJson(packageName)
|
|
29
|
+
const version = metadata.version
|
|
30
|
+
return version as string
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
static getPackagePath() {
|
|
30
|
-
return path.join(process.cwd(),
|
|
34
|
+
return path.join(process.cwd(), 'package.json')
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
static getPackageJson() {
|
|
34
|
-
return JSON.parse(fs.readFileSync(this.getPackagePath()).toString())
|
|
38
|
+
return JSON.parse(fs.readFileSync(this.getPackagePath()).toString())
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
return this.getPackageJson()
|
|
41
|
+
static getPackageVersion() {
|
|
42
|
+
return this.getPackageJson().version
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -45,36 +49,36 @@ export class Utils {
|
|
|
45
49
|
* 3.不能包含连续的小数点
|
|
46
50
|
* @param name
|
|
47
51
|
*/
|
|
48
|
-
static checkPackageName(name: string):boolean {
|
|
52
|
+
static checkPackageName(name: string): boolean {
|
|
49
53
|
// 检查包名是否以小数点结尾
|
|
50
54
|
if (name.endsWith('.')) {
|
|
51
|
-
return false
|
|
55
|
+
return false
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
// 检查包名是否包含无效字符
|
|
55
|
-
const invalidCharacters = /[\\/:*?\"<>| ]/g
|
|
59
|
+
const invalidCharacters = /[\\/:*?\"<>| ]/g
|
|
56
60
|
if (name.match(invalidCharacters)) {
|
|
57
|
-
return false
|
|
61
|
+
return false
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
// 检查包名是否至少包含一个子段
|
|
61
|
-
const segments = name.split('.')
|
|
65
|
+
const segments = name.split('.')
|
|
62
66
|
if (segments.length < 2) {
|
|
63
|
-
return false
|
|
67
|
+
return false
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
// 检查每个子段是否以字母开头
|
|
67
71
|
for (const segment of segments) {
|
|
68
72
|
if (!segment.match(/^[a-z]/)) {
|
|
69
|
-
return false
|
|
73
|
+
return false
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
// 检查子段是否包含连续的小数点
|
|
73
77
|
if (segment.includes('.' + '.')) {
|
|
74
|
-
return false
|
|
78
|
+
return false
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
return true
|
|
82
|
+
return true
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption"
|
|
3
|
-
|
|
3
|
+
v-model="widgetData"
|
|
4
4
|
@apply="save()"
|
|
5
5
|
@confirm="save({ closeWindow: true })">
|
|
6
6
|
</widget-edit-dialog>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script lang="ts" setup>
|
|
10
|
-
import {useWidget, WidgetConfigOption
|
|
10
|
+
import {useWidget, WidgetConfigOption} from "@widget-js/vue3";
|
|
11
11
|
import {WidgetData} from "@widget-js/core";
|
|
12
12
|
|
|
13
13
|
const {widgetData, widgetParams, save} = useWidget(WidgetData)
|
|
14
14
|
|
|
15
15
|
//修改成需要设置组件参数配置
|
|
16
16
|
const widgetConfigOption = new WidgetConfigOption({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
theme:{
|
|
18
|
+
backgroundColor: true,
|
|
19
|
+
borderRadius: true,
|
|
20
|
+
color:true
|
|
21
|
+
}
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
</script>
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import {Widget, WidgetKeyword} from "@widget-js/core";
|
|
2
2
|
//TODO 修改组件信息,标题,描述,关键词
|
|
3
|
-
const name = "<%= widgetName %>";
|
|
4
|
-
//组件标题
|
|
5
|
-
const title = {"zh-CN": "<%= title %>"};
|
|
6
|
-
//组件描述
|
|
7
|
-
const description = {"zh-CN": ""};
|
|
8
|
-
//组件关键词
|
|
9
|
-
const keywords = [WidgetKeyword.RECOMMEND];
|
|
10
|
-
//组件路由地址
|
|
11
|
-
const path = "/widget/<%= snakeCaseName %>";
|
|
12
|
-
//配置页路由地址
|
|
13
|
-
const configPagePath = <% if (configurable) { %>"/widget/config/<%= snakeCaseName %>"<% } else { %>undefined<% } %>;
|
|
14
|
-
//组件关键词
|
|
15
3
|
const <%= name %>Widget = new Widget({
|
|
16
|
-
name:
|
|
17
|
-
title: title,
|
|
18
|
-
description:
|
|
19
|
-
keywords:
|
|
4
|
+
name: "<%= widgetName %>",
|
|
5
|
+
title: {"zh-CN": "<%= title %>"},
|
|
6
|
+
description: {"zh-CN": ""},
|
|
7
|
+
keywords: [WidgetKeyword.RECOMMEND],
|
|
20
8
|
lang: "zh-CN",
|
|
21
9
|
width: <%= width %>,
|
|
22
10
|
height: <%= height %>,
|
|
@@ -25,8 +13,8 @@ maxWidth: <%= maxWidth %>,
|
|
|
25
13
|
minHeight: <%= minHeight %>,
|
|
26
14
|
maxHeight: <%= maxHeight %>,
|
|
27
15
|
previewImage: "修改为组件预览图地址",
|
|
28
|
-
path,
|
|
29
|
-
configPagePath
|
|
16
|
+
path: "/widget/<%= snakeCaseName %>",
|
|
17
|
+
configPagePath: <% if (configurable) { %>"/widget/config/<%= snakeCaseName %>"<% } else { %>undefined<% } %>
|
|
30
18
|
})
|
|
31
19
|
|
|
32
20
|
export default <%= name %>Widget;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RouteRecordRaw } from 'vue-router'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// FBI WANING! IMPORT PLACE, DONT DELETE THIS LINE
|
|
3
4
|
const WidgetRouter: RouteRecordRaw[] = [
|
|
4
|
-
|
|
5
|
-
]
|
|
5
|
+
// FBI WANING! ROUTE PLACE, DONT DELETE THIS LINE
|
|
6
|
+
]
|
|
6
7
|
export default WidgetRouter
|
package/test/index.test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { expect } from 'vitest'
|
|
3
|
+
import { minimatch } from 'minimatch'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
expect(minimatch(fileName,'*.ejs')).toBeTruthy()
|
|
8
|
-
expect(minimatch(fileName,'*.ts')).toBeFalsy()
|
|
5
|
+
it('minimatch', () => {
|
|
6
|
+
const fileName = path.basename('C:\\Users\\rtuge\\Desktop\\github\\widgetjs\\packages\\@widget-js\\cli\\template\\Widget.ejs')
|
|
7
|
+
expect(minimatch(fileName, '*.ejs')).toBeTruthy()
|
|
8
|
+
expect(minimatch(fileName, '*.ts')).toBeFalsy()
|
|
9
9
|
})
|
package/tsconfig.json
CHANGED
|
@@ -5,7 +5,26 @@
|
|
|
5
5
|
/* Basic Options */
|
|
6
6
|
// "incremental": true, /* Enable incremental compilation */
|
|
7
7
|
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
|
8
|
-
"
|
|
8
|
+
"lib": ["esnext"],
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
12
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
13
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
14
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
15
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
16
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
17
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
18
|
+
|
|
19
|
+
/* Additional Checks */
|
|
20
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
21
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
22
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
23
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
24
|
+
|
|
25
|
+
/* Module Resolution Options */
|
|
26
|
+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
27
|
+
"types": ["node"], /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
28
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
29
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
30
|
// "checkJs": true, /* Report errors in .js files. */
|
|
@@ -26,31 +45,17 @@
|
|
|
26
45
|
|
|
27
46
|
/* Strict Type-Checking Options */
|
|
28
47
|
"strict": true /* Enable all strict type-checking options. */,
|
|
29
|
-
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
|
|
43
|
-
/* Module Resolution Options */
|
|
44
|
-
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
48
|
+
"outDir": "lib",
|
|
45
49
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
50
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
47
51
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
48
52
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
49
53
|
/* Type declaration files to be included in compilation. */
|
|
50
|
-
// "types": ["element-plus/global"],
|
|
54
|
+
// "types": ["element-plus/global"],
|
|
51
55
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
52
56
|
// "resolveJsonModule": true,
|
|
53
57
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
58
|
+
"forceConsistentCasingInFileNames": true,
|
|
54
59
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
55
60
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
56
61
|
|
|
@@ -67,12 +72,7 @@
|
|
|
67
72
|
/* Advanced Options */
|
|
68
73
|
|
|
69
74
|
/* Skip type checking of declaration files. */
|
|
70
|
-
"skipLibCheck": true
|
|
71
|
-
"types": ["node"],
|
|
72
|
-
"rootDir": "src",
|
|
73
|
-
"outDir": "lib",
|
|
74
|
-
"lib": ["esnext"],
|
|
75
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
75
|
+
"skipLibCheck": true /* Disallow inconsistently-cased references to the same file. */
|
|
76
76
|
},
|
|
77
|
-
"include": ["src/**/*"]
|
|
77
|
+
"include": ["src/**/*"]
|
|
78
78
|
}
|
package/tsup.config.ts
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { defineConfig } from 'vite'
|
|
5
|
-
import vue from '@vitejs/plugin-vue'
|
|
6
|
-
|
|
7
|
-
// https://vitejs.dev/config/
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
plugins: [vue(), widget()],
|
|
10
|
-
resolve: {
|
|
11
|
-
alias: {
|
|
12
|
-
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
})
|
|
1
|
+
import { URL, fileURLToPath } from 'node:url'
|
|
2
|
+
import widget from '@widget-js/vite-plugin-widget'
|
|
3
|
+
|
|
4
|
+
import { defineConfig } from 'vite'
|
|
5
|
+
import vue from '@vitejs/plugin-vue'
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [vue(), widget()],
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
})
|