rollup-plugin-replace-shebang 1.0.0 → 1.2.0
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/README.md +24 -29
- package/{dist/index.esm.js → es/index.mjs} +5 -4
- package/{dist → lib}/index.js +5 -4
- package/package.json +57 -41
- package/typings/base.d.ts +9 -0
- package/typings/index.d.ts +17 -11
- package/CHANGELOG.md +0 -6
- package/dist/index.d.ts +0 -17
package/README.md
CHANGED
|
@@ -1,39 +1,19 @@
|
|
|
1
|
+
<div style="text-align: center;" align="center">
|
|
2
|
+
|
|
1
3
|
# rollup-plugin-replace-shebang
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
一个自动替换`shebang`的`rollup`插件
|
|
4
6
|
|
|
5
7
|
[![NPM version][npm-image]][npm-url]
|
|
6
8
|
[![Codacy Badge][codacy-image]][codacy-url]
|
|
7
|
-
[![build status][travis-image]][travis-url]
|
|
8
9
|
[![Test coverage][codecov-image]][codecov-url]
|
|
9
|
-
[![David deps][david-image]][david-url]
|
|
10
|
-
[![Known Vulnerabilities][snyk-image]][snyk-url]
|
|
11
10
|
[![npm download][download-image]][download-url]
|
|
12
11
|
[![gzip][gzip-image]][gzip-url]
|
|
13
12
|
[![License][license-image]][license-url]
|
|
14
13
|
|
|
15
14
|
[![Sonar][sonar-image]][sonar-url]
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
[npm-url]: https://npmjs.org/package/rollup-plugin-replace-shebang
|
|
19
|
-
[codacy-image]: https://app.codacy.com/project/badge/Grade/f70d4880e4ad4f40aa970eb9ee9d0696
|
|
20
|
-
[codacy-url]: https://www.codacy.com/gh/saqqdy/rollup-plugin-replace-shebang/dashboard?utm_source=github.com&utm_medium=referral&utm_content=saqqdy/rollup-plugin-replace-shebang&utm_campaign=Badge_Grade
|
|
21
|
-
[travis-image]: https://travis-ci.com/saqqdy/rollup-plugin-replace-shebang.svg?branch=master
|
|
22
|
-
[travis-url]: https://travis-ci.com/saqqdy/rollup-plugin-replace-shebang
|
|
23
|
-
[codecov-image]: https://img.shields.io/codecov/c/github/saqqdy/rollup-plugin-replace-shebang.svg?style=flat-square
|
|
24
|
-
[codecov-url]: https://codecov.io/github/saqqdy/rollup-plugin-replace-shebang?branch=master
|
|
25
|
-
[david-image]: https://img.shields.io/david/saqqdy/rollup-plugin-replace-shebang.svg?style=flat-square
|
|
26
|
-
[david-url]: https://david-dm.org/saqqdy/rollup-plugin-replace-shebang
|
|
27
|
-
[snyk-image]: https://snyk.io/test/npm/rollup-plugin-replace-shebang/badge.svg?style=flat-square
|
|
28
|
-
[snyk-url]: https://snyk.io/test/npm/rollup-plugin-replace-shebang
|
|
29
|
-
[download-image]: https://img.shields.io/npm/dm/rollup-plugin-replace-shebang.svg?style=flat-square
|
|
30
|
-
[download-url]: https://npmjs.org/package/rollup-plugin-replace-shebang
|
|
31
|
-
[gzip-image]: http://img.badgesize.io/https://unpkg.com/rollup-plugin-replace-shebang/dist/index.js?compression=gzip&label=gzip%20size:%20JS
|
|
32
|
-
[gzip-url]: http://img.badgesize.io/https://unpkg.com/rollup-plugin-replace-shebang/dist/index.js?compression=gzip&label=gzip%20size:%20JS
|
|
33
|
-
[license-image]: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
34
|
-
[license-url]: LICENSE
|
|
35
|
-
[sonar-image]: https://sonarcloud.io/api/project_badges/quality_gate?project=saqqdy_rollup-plugin-replace-shebang
|
|
36
|
-
[sonar-url]: https://sonarcloud.io/dashboard?id=saqqdy_rollup-plugin-replace-shebang
|
|
16
|
+
</div>
|
|
37
17
|
|
|
38
18
|
## 安装
|
|
39
19
|
|
|
@@ -48,13 +28,13 @@ $ yarn add -D rollup-plugin-replace-shebang
|
|
|
48
28
|
## 使用
|
|
49
29
|
|
|
50
30
|
```js
|
|
51
|
-
import
|
|
31
|
+
import shebang from 'rollup-plugin-replace-shebang'
|
|
52
32
|
|
|
53
33
|
plugins: [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
shebang({
|
|
35
|
+
shebang: '#!/usr/bin/env node',
|
|
36
|
+
skipBackslash: true // 跳过\u005c 反斜杠
|
|
37
|
+
})
|
|
58
38
|
]
|
|
59
39
|
```
|
|
60
40
|
|
|
@@ -65,3 +45,18 @@ Please open an issue [here](https://github.com/saqqdy/rollup-plugin-replace-sheb
|
|
|
65
45
|
## License
|
|
66
46
|
|
|
67
47
|
[MIT](LICENSE)
|
|
48
|
+
|
|
49
|
+
[npm-image]: https://img.shields.io/npm/v/rollup-plugin-replace-shebang.svg?style=flat-square
|
|
50
|
+
[npm-url]: https://npmjs.org/package/rollup-plugin-replace-shebang
|
|
51
|
+
[codacy-image]: https://app.codacy.com/project/badge/Grade/f70d4880e4ad4f40aa970eb9ee9d0696
|
|
52
|
+
[codacy-url]: https://www.codacy.com/gh/saqqdy/rollup-plugin-replace-shebang/dashboard?utm_source=github.com&utm_medium=referral&utm_content=saqqdy/rollup-plugin-replace-shebang&utm_campaign=Badge_Grade
|
|
53
|
+
[codecov-image]: https://img.shields.io/codecov/c/github/saqqdy/rollup-plugin-replace-shebang.svg?style=flat-square
|
|
54
|
+
[codecov-url]: https://codecov.io/github/saqqdy/rollup-plugin-replace-shebang?branch=master
|
|
55
|
+
[download-image]: https://img.shields.io/npm/dm/rollup-plugin-replace-shebang.svg?style=flat-square
|
|
56
|
+
[download-url]: https://npmjs.org/package/rollup-plugin-replace-shebang
|
|
57
|
+
[gzip-image]: http://img.badgesize.io/https://unpkg.com/rollup-plugin-replace-shebang/lib/index.js?compression=gzip&label=gzip%20size:%20JS
|
|
58
|
+
[gzip-url]: http://img.badgesize.io/https://unpkg.com/rollup-plugin-replace-shebang/lib/index.js?compression=gzip&label=gzip%20size:%20JS
|
|
59
|
+
[license-image]: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
60
|
+
[license-url]: LICENSE
|
|
61
|
+
[sonar-image]: https://sonarcloud.io/api/project_badges/quality_gate?project=saqqdy_rollup-plugin-replace-shebang
|
|
62
|
+
[sonar-url]: https://sonarcloud.io/dashboard?id=saqqdy_rollup-plugin-replace-shebang
|
|
@@ -10,14 +10,14 @@ import MagicString from 'magic-string';
|
|
|
10
10
|
function replaceStringPlugin(options = {}) {
|
|
11
11
|
const contextMap = new Map();
|
|
12
12
|
return {
|
|
13
|
-
name: 'replace-
|
|
13
|
+
name: 'replace-shebang',
|
|
14
14
|
|
|
15
15
|
transform(code, moduleID) {
|
|
16
16
|
let shebang;
|
|
17
17
|
code = code.replace(/^#![^\n]*/, match => (shebang = match, ''));
|
|
18
18
|
|
|
19
19
|
if (options.skipBackslash) {
|
|
20
|
-
code = code.replace(/(\\u005c|\\\\)/g, (
|
|
20
|
+
code = code.replace(/(\\u005c|\\\\)/g, () => '__u005c__');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (!shebang) return null;
|
|
@@ -33,9 +33,10 @@ function replaceStringPlugin(options = {}) {
|
|
|
33
33
|
renderChunk(code, chunk, {
|
|
34
34
|
sourcemap
|
|
35
35
|
}) {
|
|
36
|
-
|
|
36
|
+
const moduleID = chunk.facadeModuleId.replace(/\?.+$/, '');
|
|
37
|
+
const {
|
|
37
38
|
shebang
|
|
38
|
-
} = contextMap.get(
|
|
39
|
+
} = contextMap.get(moduleID) || {};
|
|
39
40
|
if (!shebang) return null;
|
|
40
41
|
|
|
41
42
|
if (options.skipBackslash) {
|
package/{dist → lib}/index.js
RENAMED
|
@@ -16,14 +16,14 @@ var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
|
16
16
|
function replaceStringPlugin(options = {}) {
|
|
17
17
|
const contextMap = new Map();
|
|
18
18
|
return {
|
|
19
|
-
name: 'replace-
|
|
19
|
+
name: 'replace-shebang',
|
|
20
20
|
|
|
21
21
|
transform(code, moduleID) {
|
|
22
22
|
let shebang;
|
|
23
23
|
code = code.replace(/^#![^\n]*/, match => (shebang = match, ''));
|
|
24
24
|
|
|
25
25
|
if (options.skipBackslash) {
|
|
26
|
-
code = code.replace(/(\\u005c|\\\\)/g, (
|
|
26
|
+
code = code.replace(/(\\u005c|\\\\)/g, () => '__u005c__');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (!shebang) return null;
|
|
@@ -39,9 +39,10 @@ function replaceStringPlugin(options = {}) {
|
|
|
39
39
|
renderChunk(code, chunk, {
|
|
40
40
|
sourcemap
|
|
41
41
|
}) {
|
|
42
|
-
|
|
42
|
+
const moduleID = chunk.facadeModuleId.replace(/\?.+$/, '');
|
|
43
|
+
const {
|
|
43
44
|
shebang
|
|
44
|
-
} = contextMap.get(
|
|
45
|
+
} = contextMap.get(moduleID) || {};
|
|
45
46
|
if (!shebang) return null;
|
|
46
47
|
|
|
47
48
|
if (options.skipBackslash) {
|
package/package.json
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup-plugin-replace-shebang",
|
|
3
|
-
"version": "1.0.0",
|
|
4
3
|
"description": "一个自动替换shebang的rollup插件",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
4
|
+
"version": "1.2.0",
|
|
5
|
+
"packageManager": "pnpm@7.7.0",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "es/index.mjs",
|
|
8
|
+
"typings": "typings/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": "./es/index.mjs",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"es",
|
|
16
|
+
"lib",
|
|
17
|
+
"typings"
|
|
18
|
+
],
|
|
9
19
|
"scripts": {
|
|
10
20
|
"release": "npm run -s prepare && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish",
|
|
11
|
-
"
|
|
21
|
+
"gen:version": "tscjs scripts/version",
|
|
22
|
+
"build": "rimraf dist es lib && rollup -c",
|
|
12
23
|
"build:types": "run-s build-temp-types roll-types",
|
|
13
24
|
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/ -p src/",
|
|
14
25
|
"patch-types": "node script/patchTypes",
|
|
15
26
|
"roll-types": "api-extractor run && rimraf temp",
|
|
16
27
|
"dev": "rollup -c -w",
|
|
28
|
+
"pub": "tscjs scripts/publish",
|
|
29
|
+
"unpub": "tscjs scripts/unpublish",
|
|
30
|
+
"sync": "tscjs scripts/sync",
|
|
17
31
|
"dist": "run-s eslint prettier build build:types",
|
|
18
32
|
"docs": "rimraf docs && typedoc",
|
|
19
33
|
"eslint": "eslint --fix --ext .ts,.js",
|
|
20
34
|
"prettier": "prettier --write \"**/*.{js,ts,json,md}\"",
|
|
21
35
|
"prettier:docs": "prettier --write \"**/*.md\""
|
|
22
36
|
},
|
|
23
|
-
"exports": {
|
|
24
|
-
"import": "./dist/index.esm.js",
|
|
25
|
-
"default": "./dist/index.js"
|
|
26
|
-
},
|
|
27
|
-
"files": [
|
|
28
|
-
"dist",
|
|
29
|
-
"es",
|
|
30
|
-
"typings"
|
|
31
|
-
],
|
|
32
37
|
"directories": {
|
|
33
38
|
"es": "es",
|
|
34
39
|
"lib": "lib",
|
|
@@ -37,40 +42,36 @@
|
|
|
37
42
|
"typings": "typings"
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
|
-
"magic-string": "^0.
|
|
45
|
+
"magic-string": "^0.26.2"
|
|
41
46
|
},
|
|
42
47
|
"devDependencies": {
|
|
43
|
-
"@babel/core": "^7.
|
|
44
|
-
"@babel/preset-env": "^7.
|
|
45
|
-
"@babel/preset-typescript": "^7.
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@rollup/plugin-
|
|
49
|
-
"@rollup/plugin-
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"eslint": "^7.19.0",
|
|
55
|
-
"eslint-config-sets": "^1.5.1",
|
|
48
|
+
"@babel/core": "^7.18.13",
|
|
49
|
+
"@babel/preset-env": "^7.18.10",
|
|
50
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
51
|
+
"@eslint-sets/eslint-config-simple-ts": "^3.0.4",
|
|
52
|
+
"@microsoft/api-extractor": "^7.29.5",
|
|
53
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
54
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
55
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
56
|
+
"@types/node": "^18.7.13",
|
|
57
|
+
"esbuild": "^0.15.5",
|
|
58
|
+
"eslint": "^8.22.0",
|
|
56
59
|
"npm-run-all": "^4.1.5",
|
|
57
|
-
"prettier": "^2.
|
|
60
|
+
"prettier": "^2.7.1",
|
|
61
|
+
"prettier-config-common": "^1.2.1",
|
|
58
62
|
"rimraf": "^3.0.2",
|
|
59
|
-
"rollup": "^2.
|
|
63
|
+
"rollup": "^2.78.1",
|
|
60
64
|
"rollup-plugin-terser": "^7.0.2",
|
|
61
|
-
"rollup-plugin-typescript2": "^0.
|
|
62
|
-
"rollup-plugin-visualizer": "^5.
|
|
63
|
-
"
|
|
64
|
-
"typedoc
|
|
65
|
-
"
|
|
65
|
+
"rollup-plugin-typescript2": "^0.33.0",
|
|
66
|
+
"rollup-plugin-visualizer": "^5.8.0",
|
|
67
|
+
"tsnd": "^1.1.0",
|
|
68
|
+
"typedoc": "^0.23.10",
|
|
69
|
+
"typedoc-plugin-markdown": "^3.13.4",
|
|
70
|
+
"typescript": "^4.7.4"
|
|
66
71
|
},
|
|
67
72
|
"peerDependencies": {
|
|
68
73
|
"rollup": ">= 2.0.0"
|
|
69
74
|
},
|
|
70
|
-
"repository": {
|
|
71
|
-
"type": "git",
|
|
72
|
-
"url": "git+https://github.com/saqqdy/rollup-plugin-replace-shebang.git"
|
|
73
|
-
},
|
|
74
75
|
"keywords": [
|
|
75
76
|
"rollup",
|
|
76
77
|
"plugin",
|
|
@@ -79,8 +80,23 @@
|
|
|
79
80
|
"hashbang",
|
|
80
81
|
"saqqdy"
|
|
81
82
|
],
|
|
82
|
-
"
|
|
83
|
+
"pnpm": {
|
|
84
|
+
"peerDependencyRules": {
|
|
85
|
+
"ignoreMissing": [
|
|
86
|
+
"tslib",
|
|
87
|
+
"webpack"
|
|
88
|
+
],
|
|
89
|
+
"allowedVersions": {
|
|
90
|
+
"eslint": "^8.0.0"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
83
94
|
"license": "MIT",
|
|
95
|
+
"author": "saqqdy <saqqdy@qq.com> (https://github.com/saqqdy)",
|
|
96
|
+
"repository": {
|
|
97
|
+
"type": "git",
|
|
98
|
+
"url": "git+https://github.com/saqqdy/rollup-plugin-replace-shebang.git"
|
|
99
|
+
},
|
|
84
100
|
"bugs": {
|
|
85
101
|
"url": "https://github.com/saqqdy/rollup-plugin-replace-shebang/issues"
|
|
86
102
|
},
|
package/typings/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Plugin as Plugin_2 } from 'rollup';
|
|
2
|
+
|
|
3
|
+
export declare interface Options {
|
|
4
|
+
shebang?: string;
|
|
5
|
+
skipBackslash?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 一个自动替换shebang的rollup插件
|
|
10
|
+
*
|
|
11
|
+
* @param options - 配置参数
|
|
12
|
+
* @returns Plugin - 插件
|
|
13
|
+
*/
|
|
14
|
+
declare function replaceStringPlugin(options?: Options): Plugin_2;
|
|
15
|
+
export default replaceStringPlugin;
|
|
16
|
+
|
|
17
|
+
export { }
|
package/CHANGELOG.md
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Plugin as Plugin_2 } from 'rollup';
|
|
2
|
-
|
|
3
|
-
export declare interface ReplaceStringOptions {
|
|
4
|
-
shebang?: string;
|
|
5
|
-
skipBackslash?: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 一个自动替换shebang的rollup插件
|
|
10
|
-
*
|
|
11
|
-
* @param options - 配置参数
|
|
12
|
-
* @returns Plugin - 插件
|
|
13
|
-
*/
|
|
14
|
-
declare function replaceStringPlugin(options?: ReplaceStringOptions): Plugin_2;
|
|
15
|
-
export default replaceStringPlugin;
|
|
16
|
-
|
|
17
|
-
export { }
|