@deppon/deppon-norm 2.1.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/LICENSE +21 -0
- package/README.md +119 -0
- package/es/_virtual/_rollup-plugin-inject-process-env.js +11 -0
- package/es/commit/index.d.ts +6 -0
- package/es/commit/index.js +10 -0
- package/es/composable.d.ts +20 -0
- package/es/composable.js +43 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +7 -0
- package/es/note/index.d.ts +6 -0
- package/es/note/index.js +10 -0
- package/es/start/index.d.ts +6 -0
- package/es/start/index.js +10 -0
- package/es/stylelint/index.d.ts +6 -0
- package/es/stylelint/index.js +10 -0
- package/es/vue.d.ts +10 -0
- package/es/vue.js +19 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 xingxing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# `@deppon/deppon-norm`
|
|
2
|
+
|
|
3
|
+
德邦前端 norm 包
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @deppon/deppon-norm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 基础使用
|
|
12
|
+
|
|
13
|
+
### JavaScript/TypeScript 项目
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { commit, note, start, stylelint } from '@deppon/deppon-norm';
|
|
17
|
+
|
|
18
|
+
// 使用 commit
|
|
19
|
+
commit('commit message');
|
|
20
|
+
|
|
21
|
+
// 使用 note
|
|
22
|
+
note('note message');
|
|
23
|
+
|
|
24
|
+
// 使用 start
|
|
25
|
+
start('start message');
|
|
26
|
+
|
|
27
|
+
// 使用 stylelint
|
|
28
|
+
stylelint('stylelint message');
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Vue 3 使用
|
|
32
|
+
|
|
33
|
+
### 1. 安装插件
|
|
34
|
+
|
|
35
|
+
在 Vue 应用中安装插件:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import { createApp } from 'vue';
|
|
39
|
+
import { VuePlugin } from '@deppon/deppon-norm';
|
|
40
|
+
|
|
41
|
+
const app = createApp(App);
|
|
42
|
+
|
|
43
|
+
// 安装插件
|
|
44
|
+
app.use(VuePlugin);
|
|
45
|
+
|
|
46
|
+
app.mount('#app');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. 在 Composition API 中使用
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<script setup>
|
|
53
|
+
import { useNorm } from '@deppon/deppon-norm';
|
|
54
|
+
|
|
55
|
+
const norm = useNorm();
|
|
56
|
+
|
|
57
|
+
const handleCommit = () => {
|
|
58
|
+
norm.commit('commit message');
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleNote = () => {
|
|
62
|
+
norm.note('note message');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleStart = () => {
|
|
66
|
+
norm.start('start message');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleStylelint = () => {
|
|
70
|
+
norm.stylelint('stylelint message');
|
|
71
|
+
};
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<button @click="handleCommit">Commit</button>
|
|
76
|
+
<button @click="handleNote">Note</button>
|
|
77
|
+
<button @click="handleStart">Start</button>
|
|
78
|
+
<button @click="handleStylelint">Stylelint</button>
|
|
79
|
+
</template>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3. 在 Options API 中使用
|
|
83
|
+
|
|
84
|
+
```vue
|
|
85
|
+
<script>
|
|
86
|
+
export default {
|
|
87
|
+
methods: {
|
|
88
|
+
handleCommit() {
|
|
89
|
+
// 通过 this.$norm 访问
|
|
90
|
+
this.$norm.commit('commit message');
|
|
91
|
+
},
|
|
92
|
+
handleNote() {
|
|
93
|
+
this.$norm.note('note message');
|
|
94
|
+
},
|
|
95
|
+
handleStart() {
|
|
96
|
+
this.$norm.start('start message');
|
|
97
|
+
},
|
|
98
|
+
handleStylelint() {
|
|
99
|
+
this.$norm.stylelint('stylelint message');
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
</script>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## API
|
|
107
|
+
|
|
108
|
+
### Composition API
|
|
109
|
+
|
|
110
|
+
- `useNorm()` - 获取 norm 实例
|
|
111
|
+
|
|
112
|
+
### 方法
|
|
113
|
+
|
|
114
|
+
- `commit(param1)` - Commit 方法
|
|
115
|
+
- `note(param1)` - Note 方法
|
|
116
|
+
- `start(param1)` - Start 方法
|
|
117
|
+
- `stylelint(param1)` - Stylelint 方法
|
|
118
|
+
|
|
119
|
+
更多 API 请参考源码。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const env = {};
|
|
3
|
+
try {
|
|
4
|
+
if (process) {
|
|
5
|
+
process.env = Object.assign({}, process.env);
|
|
6
|
+
Object.assign(process.env, env);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
10
|
+
globalThis.process = { env:env };
|
|
11
|
+
})();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition API: useNorm
|
|
3
|
+
* 在 Vue 3 Composition API 中使用 norm
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { useNorm } from '@deppon/deppon-norm/vue'
|
|
7
|
+
*
|
|
8
|
+
* export default {
|
|
9
|
+
* setup() {
|
|
10
|
+
* const norm = useNorm()
|
|
11
|
+
*
|
|
12
|
+
* const handleCommit = () => {
|
|
13
|
+
* norm.commit('commit message')
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* return { handleCommit }
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
export function useNorm(): any;
|
package/es/composable.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import './_virtual/_rollup-plugin-inject-process-env.js';
|
|
2
|
+
import { inject, getCurrentInstance } from 'vue';
|
|
3
|
+
import * as index from './index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Composition API: useNorm
|
|
7
|
+
* 在 Vue 3 Composition API 中使用 norm
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { useNorm } from '@deppon/deppon-norm/vue'
|
|
11
|
+
*
|
|
12
|
+
* export default {
|
|
13
|
+
* setup() {
|
|
14
|
+
* const norm = useNorm()
|
|
15
|
+
*
|
|
16
|
+
* const handleCommit = () => {
|
|
17
|
+
* norm.commit('commit message')
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* return { handleCommit }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
function useNorm() {
|
|
25
|
+
// 优先从 provide 获取
|
|
26
|
+
var normFromProvide = inject('depponNorm', null);
|
|
27
|
+
|
|
28
|
+
// 如果 provide 中没有,尝试从实例获取
|
|
29
|
+
if (!normFromProvide) {
|
|
30
|
+
var instance = getCurrentInstance();
|
|
31
|
+
if (instance) {
|
|
32
|
+
return instance.appContext.config.globalProperties.$norm;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 如果都没有,返回默认实例并提示
|
|
37
|
+
if (!normFromProvide) {
|
|
38
|
+
return index;
|
|
39
|
+
}
|
|
40
|
+
return normFromProvide;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { useNorm };
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as commit } from "./commit/index";
|
|
2
|
+
export { default as note } from "./note/index";
|
|
3
|
+
export { default as start } from "./start/index";
|
|
4
|
+
export { default as stylelint } from "./stylelint/index";
|
|
5
|
+
export { default as VuePlugin } from "./vue";
|
|
6
|
+
export { useNorm } from "./composable";
|
package/es/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './_virtual/_rollup-plugin-inject-process-env.js';
|
|
2
|
+
export { default as commit } from './commit/index.js';
|
|
3
|
+
export { default as note } from './note/index.js';
|
|
4
|
+
export { default as start } from './start/index.js';
|
|
5
|
+
export { default as stylelint } from './stylelint/index.js';
|
|
6
|
+
export { default as VuePlugin } from './vue.js';
|
|
7
|
+
export { useNorm } from './composable.js';
|
package/es/note/index.js
ADDED
package/es/vue.d.ts
ADDED
package/es/vue.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './_virtual/_rollup-plugin-inject-process-env.js';
|
|
2
|
+
import * as index from './index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Vue 插件安装函数
|
|
6
|
+
* @param {Object} app - Vue 应用实例
|
|
7
|
+
*/
|
|
8
|
+
function install(app) {
|
|
9
|
+
// 注册全局属性
|
|
10
|
+
app.config.globalProperties.$norm = index;
|
|
11
|
+
|
|
12
|
+
// 提供实例,供 Composition API 使用
|
|
13
|
+
app.provide('depponNorm', index);
|
|
14
|
+
}
|
|
15
|
+
var vue = {
|
|
16
|
+
install: install
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { vue as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deppon/deppon-norm",
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"main": "es/index.js",
|
|
5
|
+
"module": "es/index.js",
|
|
6
|
+
"typings": "es/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "ts-node build.ts",
|
|
10
|
+
"publish:auto": "npm publish"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://devrepo.devcloud.cn-east-3.huaweicloud.com/artgalaxy/api/npm/cn-east-3_8a2e1f0ee52d4adb9a0a6998d78d0dda_npm_1/"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": ""
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"es"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"description": "德邦前端 norm 包",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"norm",
|
|
27
|
+
"react-library",
|
|
28
|
+
"vue",
|
|
29
|
+
"vue3"
|
|
30
|
+
],
|
|
31
|
+
"author": {
|
|
32
|
+
"name": "",
|
|
33
|
+
"email": ""
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@babel/runtime": "^7.17.7"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"vue": "^3.0.0"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "1f329a64567c2e22df7860b0918ebe3427718945"
|
|
42
|
+
}
|