rollup-plugin-replace-shebang 1.0.0 → 1.1.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 CHANGED
@@ -1,39 +1,19 @@
1
+ <div style="text-align: center;" align="center">
2
+
1
3
  # rollup-plugin-replace-shebang
2
4
 
3
- 一个自动替换 shebangrollup 插件
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
- [npm-image]: https://img.shields.io/npm/v/rollup-plugin-replace-shebang.svg?style=flat-square
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 replaceString from 'rollup-plugin-replace-shebang'
31
+ import shebang from 'rollup-plugin-replace-shebang'
52
32
 
53
33
  plugins: [
54
- replaceString({
55
- shebang: '#!/usr/bin/env node',
56
- skipBackslash: true // 跳过\u005c 反斜杠
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-string',
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, (a, b) => '__u005c__');
20
+ code = code.replace(/(\\u005c|\\\\)/g, () => '__u005c__');
21
21
  }
22
22
 
23
23
  if (!shebang) return null;
@@ -33,7 +33,7 @@ function replaceStringPlugin(options = {}) {
33
33
  renderChunk(code, chunk, {
34
34
  sourcemap
35
35
  }) {
36
- let {
36
+ const {
37
37
  shebang
38
38
  } = contextMap.get(chunk.facadeModuleId) || {};
39
39
  if (!shebang) return null;
@@ -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-string',
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, (a, b) => '__u005c__');
26
+ code = code.replace(/(\\u005c|\\\\)/g, () => '__u005c__');
27
27
  }
28
28
 
29
29
  if (!shebang) return null;
@@ -39,7 +39,7 @@ function replaceStringPlugin(options = {}) {
39
39
  renderChunk(code, chunk, {
40
40
  sourcemap
41
41
  }) {
42
- let {
42
+ const {
43
43
  shebang
44
44
  } = contextMap.get(chunk.facadeModuleId) || {};
45
45
  if (!shebang) return null;
package/package.json CHANGED
@@ -1,14 +1,24 @@
1
1
  {
2
2
  "name": "rollup-plugin-replace-shebang",
3
- "version": "1.0.0",
4
3
  "description": "一个自动替换shebang的rollup插件",
5
- "main": "dist/index.js",
6
- "unpkg": "dist/index.js",
7
- "module": "dist/index.esm.js",
8
- "typings": "dist/index.d.ts",
4
+ "version": "1.1.0",
5
+ "main": "lib/index.js",
6
+ "module": "es/index.mjs",
7
+ "typings": "typings/index.d.ts",
8
+ "exports": {
9
+ "import": "./es/index.mjs",
10
+ "default": "./lib/index.js"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "es",
15
+ "lib",
16
+ "typings"
17
+ ],
9
18
  "scripts": {
10
19
  "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
- "build": "rimraf dist es && rollup -c",
20
+ "gen:version": "tscjs scripts/version",
21
+ "build": "rimraf dist es lib && rollup -c",
12
22
  "build:types": "run-s build-temp-types roll-types",
13
23
  "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/ -p src/",
14
24
  "patch-types": "node script/patchTypes",
@@ -20,15 +30,6 @@
20
30
  "prettier": "prettier --write \"**/*.{js,ts,json,md}\"",
21
31
  "prettier:docs": "prettier --write \"**/*.md\""
22
32
  },
23
- "exports": {
24
- "import": "./dist/index.esm.js",
25
- "default": "./dist/index.js"
26
- },
27
- "files": [
28
- "dist",
29
- "es",
30
- "typings"
31
- ],
32
33
  "directories": {
33
34
  "es": "es",
34
35
  "lib": "lib",
@@ -37,40 +38,36 @@
37
38
  "typings": "typings"
38
39
  },
39
40
  "dependencies": {
40
- "magic-string": "^0.25.7"
41
+ "magic-string": "^0.26.1"
41
42
  },
42
43
  "devDependencies": {
43
- "@babel/core": "^7.15.5",
44
- "@babel/preset-env": "^7.15.4",
45
- "@babel/preset-typescript": "^7.15.0",
46
- "@microsoft/api-extractor": "^7.18.7",
47
- "@rollup/plugin-babel": "^5.2.2",
48
- "@rollup/plugin-commonjs": "^20.0.0",
49
- "@rollup/plugin-node-resolve": "^13.0.4",
50
- "@typescript-eslint/eslint-plugin": "^4.31.0",
51
- "@typescript-eslint/parser": "^4.31.0",
52
- "babel-loader": "^8.2.2",
53
- "esbuild": "^0.12.25",
54
- "eslint": "^7.19.0",
55
- "eslint-config-sets": "^1.5.1",
44
+ "@babel/core": "^7.17.10",
45
+ "@babel/preset-env": "^7.17.10",
46
+ "@babel/preset-typescript": "^7.16.7",
47
+ "@eslint-sets/eslint-config-simple-ts": "^2.1.4",
48
+ "@microsoft/api-extractor": "^7.23.0",
49
+ "@rollup/plugin-babel": "^5.3.1",
50
+ "@rollup/plugin-commonjs": "^22.0.0",
51
+ "@rollup/plugin-node-resolve": "^13.2.1",
52
+ "@saqqdy/prettier-config": "^1.1.2",
53
+ "@types/node": "^17.0.31",
54
+ "esbuild": "^0.14.38",
55
+ "eslint": "^8.14.0",
56
56
  "npm-run-all": "^4.1.5",
57
- "prettier": "^2.2.1",
57
+ "prettier": "^2.6.2",
58
58
  "rimraf": "^3.0.2",
59
- "rollup": "^2.58.0",
59
+ "rollup": "^2.71.1",
60
60
  "rollup-plugin-terser": "^7.0.2",
61
- "rollup-plugin-typescript2": "^0.30.0",
62
- "rollup-plugin-visualizer": "^5.5.2",
63
- "typedoc": "^0.21.9",
64
- "typedoc-plugin-markdown": "^3.10.4",
65
- "typescript": "^4.4.2"
61
+ "rollup-plugin-typescript2": "^0.31.2",
62
+ "rollup-plugin-visualizer": "^5.6.0",
63
+ "tsnd": "^1.0.2",
64
+ "typedoc": "^0.22.15",
65
+ "typedoc-plugin-markdown": "^3.12.1",
66
+ "typescript": "^4.6.4"
66
67
  },
67
68
  "peerDependencies": {
68
69
  "rollup": ">= 2.0.0"
69
70
  },
70
- "repository": {
71
- "type": "git",
72
- "url": "git+https://github.com/saqqdy/rollup-plugin-replace-shebang.git"
73
- },
74
71
  "keywords": [
75
72
  "rollup",
76
73
  "plugin",
@@ -79,8 +76,12 @@
79
76
  "hashbang",
80
77
  "saqqdy"
81
78
  ],
82
- "author": "saqqdy <saqqdy@qq.com> (https://www.saqqdy.com)",
83
79
  "license": "MIT",
80
+ "author": "saqqdy <saqqdy@qq.com> (https://github.com/saqqdy)",
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "git+https://github.com/saqqdy/rollup-plugin-replace-shebang.git"
84
+ },
84
85
  "bugs": {
85
86
  "url": "https://github.com/saqqdy/rollup-plugin-replace-shebang/issues"
86
87
  },
@@ -0,0 +1,9 @@
1
+ export type AnyObject = Record<string, any>
2
+
3
+ export interface AnyFunction extends AnyObject {
4
+ (...args: any[]): any
5
+ }
6
+
7
+ export type ArrayOneMore<T> = {
8
+ 0: T
9
+ } & Array<T>
@@ -1,11 +1,17 @@
1
- export interface AnyObject {
2
- [prop: string]: any
3
- }
4
-
5
- export interface AnyFunction extends AnyObject {
6
- (...args: any[]): any
7
- }
8
-
9
- export type ArrayOneMore<T> = {
10
- 0: T
11
- } & Array<T>
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
@@ -1,6 +0,0 @@
1
- # 更新日志
2
-
3
- ## 2021.10.22 v1.0.0 更新日志
4
-
5
- 1. 支持传入`shebang` `skipBackslash`两个参数
6
- 2. 完善文档
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 { }