Skip to content

Commit 0970224

Browse files
committed
bookmark-script 模板工具
1 parent 0da8f69 commit 0970224

63 files changed

Lines changed: 1172 additions & 11 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/brave-birds-work.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@xiaohuohumax/create-bookmark-script": major
3+
---
4+
5+
bookmark-script 模板工具

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"keywords": [
1919
"bookmark",
2020
"builder",
21-
"script"
21+
"script",
22+
"bookmarklet",
23+
"npm create"
2224
],
2325
"author": "xiaohuohumax",
2426
"license": "MIT",

packages/bookmark-script/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@ javascript:(function(){alert("Hello, World!");})();void(0);
1515

1616
## 使用
1717

18-
### 添加依赖
18+
### 1. 模板创建
19+
20+
```shell
21+
npm create @xiaohuohumax/bookmark-script
22+
# 选择模板
23+
```
24+
25+
### 2. 自行创建
26+
27+
#### 添加依赖
1928

2029
```shell
2130
npm i @xiaohuohumax/bookmark-script
2231
```
2332

24-
### 编写配置文件
33+
#### 编写配置文件
2534

2635
```txt
2736
project
@@ -54,7 +63,7 @@ export default defineConfig({
5463
});
5564
```
5665

57-
### 添加智能提示 (可选)
66+
#### 添加智能提示 (可选)
5867

5968
tsconfig.json
6069

@@ -68,7 +77,7 @@ tsconfig.json
6877
}
6978
```
7079

71-
### 编写书签脚本
80+
#### 编写书签脚本
7281

7382
```ts
7483
// index.ts
@@ -77,7 +86,7 @@ tsconfig.json
7786
alert(new Date());
7887
```
7988

80-
### 打包构建
89+
#### 打包构建
8190

8291
修改 `package.json`
8392

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 xiaohuohumax
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.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# @xiaohuohumax/create-bookmark-script
2+
3+
**创建 [书签脚本打包工具 Bookmarklet Cli](https://github.com/xiaohuohumax/bookmark-script-builder/tree/main/packages/bookmark-script#readme) 模板**
4+
5+
## 使用
6+
7+
```shell
8+
npm create @xiaohuohumax/bookmark-script
9+
```
10+
11+
## 模板包含
12+
13+
+ JavaScript
14+
+ Vue
15+
+ React
16+
17+
## 最后
18+
19+
玩的开心 🎉🎉🎉🎉
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import './dist/index.mjs';
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@xiaohuohumax/create-bookmark-script",
3+
"version": "0.0.0",
4+
"description": "书签脚本打包工具 Bookmarklet Cli 模板",
5+
"type": "module",
6+
"scripts": {
7+
"build": "rollup -c",
8+
"dev": "rollup -c --watch --watch.include src/**"
9+
},
10+
"keywords": [
11+
"bookmarklet",
12+
"bookmark-script",
13+
"npm create"
14+
],
15+
"author": "xiaohuohumax",
16+
"license": "MIT",
17+
"homepage": "https://github.com/xiaohuohumax/bookmark-script-builder/tree/main/packages/create-bookmark-script#readme",
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/xiaohuohumax/bookmark-script-builder.git",
21+
"directory": "packages/create-bookmark-script"
22+
},
23+
"bin": {
24+
"create-bookmark-script": "index.mjs"
25+
},
26+
"dependencies": {
27+
"chalk": "^5.3.0",
28+
"prompts": "^2.4.2"
29+
},
30+
"devDependencies": {
31+
"@types/prompts": "^2.4.9",
32+
"@types/yargs": "^17.0.32",
33+
"rollup": "^4.12.1",
34+
"rollup-plugin-esbuild": "^6.1.1"
35+
},
36+
"files": [
37+
"dist",
38+
"*.mjs",
39+
"template-*"
40+
]
41+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { defineConfig } from 'rollup';
2+
import esbuild from 'rollup-plugin-esbuild';
3+
4+
import { builtinModules } from 'node:module';
5+
import fs from 'node:fs';
6+
7+
const pkg = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf-8' }));
8+
9+
const entries = {
10+
index: 'src/index.ts',
11+
};
12+
13+
const banner = `/**
14+
* ${pkg.name} ${pkg.version}
15+
* Copyright (c) 2020-present ${pkg.author}
16+
* @license ${pkg.license}
17+
*/`;
18+
19+
const external = [
20+
...Object.keys(pkg.dependencies ?? {}),
21+
...builtinModules,
22+
'node:path',
23+
'node:fs',
24+
];
25+
26+
export default defineConfig([
27+
{
28+
input: entries,
29+
output: {
30+
dir: 'dist',
31+
banner,
32+
format: 'esm',
33+
entryFileNames: '[name].mjs',
34+
},
35+
plugins: [
36+
esbuild()
37+
],
38+
external
39+
}
40+
]);

0 commit comments

Comments
 (0)