浏览代码

Improved pre-commit and pre-publish workflows
Installed `npm` package now has `types` directory and doesn't have `src` directory

sanex 3 年之前
父节点
当前提交
0306f29ba8
共有 13 个文件被更改,包括 60 次插入144 次删除
  1. 2 1
      .gitignore
  2. 1 0
      .npmignore
  3. 1 0
      CHANGELOG.md
  4. 0 1
      dist/index.browser.js
  5. 0 52
      dist/index.browser.js.LICENSE.txt
  6. 0 1
      dist/index.cli.js
  7. 0 23
      dist/index.cli.js.LICENSE.txt
  8. 0 1
      dist/index.js
  9. 0 23
      dist/index.js.LICENSE.txt
  10. 0 38
      index.d.ts
  11. 39 0
      index.ts
  12. 4 4
      package.json
  13. 13 0
      src/tsconfig.declarations.json

+ 2 - 1
.gitignore

@@ -1,8 +1,9 @@
-.awcache
 .DS_Store
 .idea
 .nyc_output
 coverage
+/dist
+/types
 npm-debug.log
 *.js.map
 /coverage

+ 1 - 0
.npmignore

@@ -6,4 +6,5 @@ coverage
 examples
 images
 webpack
+src
 test

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@ v2.19.0
 ---
 * Fixed very rare cases when `rotateStringArray` couldn't rotate array properly
 * Improved `selfDefending` option
+* Installed `npm` package now has `types` directory and doesn't have `src` directory
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/959
 
 v2.18.1

文件差异内容过多而无法显示
+ 0 - 1
dist/index.browser.js


+ 0 - 52
dist/index.browser.js.LICENSE.txt

@@ -1,52 +0,0 @@
-/*!
- * Determine if an object is a Buffer
- *
- * @author   Feross Aboukhadijeh <https://feross.org>
- * @license  MIT
- */
-
-/*!
- * The buffer module from node.js, for the browser.
- *
- * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
- * @license  MIT
- */
-
-/*!
-Copyright (C) 2016-2020 Timofey Kachalov <[email protected]>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-  * Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
-  * Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*! *****************************************************************************
-Copyright (C) Microsoft. All rights reserved.
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use
-this file except in compliance with the License. You may obtain a copy of the
-License at http://www.apache.org/licenses/LICENSE-2.0
-
-THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
-WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
-MERCHANTABLITY OR NON-INFRINGEMENT.
-
-See the Apache Version 2.0 License for specific language governing permissions
-and limitations under the License.
-***************************************************************************** */

文件差异内容过多而无法显示
+ 0 - 1
dist/index.cli.js


+ 0 - 23
dist/index.cli.js.LICENSE.txt

@@ -1,23 +0,0 @@
-/*!
-Copyright (C) 2016-2020 Timofey Kachalov <[email protected]>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-  * Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
-  * Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/

文件差异内容过多而无法显示
+ 0 - 1
dist/index.js


+ 0 - 23
dist/index.js.LICENSE.txt

@@ -1,23 +0,0 @@
-/*!
-Copyright (C) 2016-2020 Timofey Kachalov <[email protected]>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-  * Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
-  * Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/

+ 0 - 38
index.d.ts

@@ -1,38 +0,0 @@
-import { TDictionary } from './src/types/TDictionary';
-import { TInputOptions } from './src/types/options/TInputOptions';
-import { TObfuscationResultsObject } from './src/types/TObfuscationResultsObject';
-import { TOptionsPreset } from './src/types/options/TOptionsPreset';
-
-import { IObfuscationResult } from './src/interfaces/source-code/IObfuscationResult';
-
-export type ObfuscatorOptions = TInputOptions;
-
-export interface ObfuscationResult extends IObfuscationResult {}
-
-/**
- * @param {string} sourceCode
- * @param {ObfuscatorOptions} inputOptions
- * @returns {ObfuscatedCode}
- */
-export function obfuscate (sourceCode: string, inputOptions?: ObfuscatorOptions): ObfuscationResult;
-
-/**
- * @param {TSourceCodesObject} sourceCodesObject
- * @param {TInputOptions} inputOptions
- * @returns {TObfuscationResultsObject<TSourceCodesObject>}
- */
-export function obfuscateMultiple <TSourceCodesObject extends TDictionary<string>> (
-    sourceCodesObject: TSourceCodesObject,
-    inputOptions?: TInputOptions
-): TObfuscationResultsObject<TSourceCodesObject>;
-
-/**
- * @param {TOptionsPreset} optionsPreset
- * @returns {TInputOptions}
- */
-export function getOptionsByPreset (optionsPreset: TOptionsPreset): TInputOptions;
-
-/**
- * @type {string}
- */
-export const version: string;

+ 39 - 0
index.ts

@@ -1,5 +1,44 @@
 "use strict";
 
+import { TDictionary } from './src/types/TDictionary';
+import { TInputOptions } from './src/types/options/TInputOptions';
+import { TObfuscationResultsObject } from './src/types/TObfuscationResultsObject';
+import { TOptionsPreset } from './src/types/options/TOptionsPreset';
+
+import { IObfuscationResult } from './src/interfaces/source-code/IObfuscationResult';
+
 import { JavaScriptObfuscator } from './src/JavaScriptObfuscatorFacade';
 
+export type ObfuscatorOptions = TInputOptions;
+
+export interface ObfuscationResult extends IObfuscationResult {}
+
+/**
+ * @param {string} sourceCode
+ * @param {ObfuscatorOptions} inputOptions
+ * @returns {ObfuscatedCode}
+ */
+export declare function obfuscate (sourceCode: string, inputOptions?: ObfuscatorOptions): ObfuscationResult;
+
+/**
+ * @param {TSourceCodesObject} sourceCodesObject
+ * @param {TInputOptions} inputOptions
+ * @returns {TObfuscationResultsObject<TSourceCodesObject>}
+ */
+export declare function obfuscateMultiple <TSourceCodesObject extends TDictionary<string>> (
+    sourceCodesObject: TSourceCodesObject,
+    inputOptions?: TInputOptions
+): TObfuscationResultsObject<TSourceCodesObject>;
+
+/**
+ * @param {TOptionsPreset} optionsPreset
+ * @returns {TInputOptions}
+ */
+export declare function getOptionsByPreset (optionsPreset: TOptionsPreset): TInputOptions;
+
+/**
+ * @type {string}
+ */
+export declare const version: string;
+
 module.exports = JavaScriptObfuscator;

+ 4 - 4
package.json

@@ -19,7 +19,7 @@
   "bin": {
     "javascript-obfuscator": "./bin/javascript-obfuscator"
   },
-  "types": "index.d.ts",
+  "types": "types/index.d.ts",
   "dependencies": {
     "@javascript-obfuscator/escodegen": "2.2.1",
     "@javascript-obfuscator/estraverse": "5.3.0",
@@ -114,11 +114,11 @@
     "test": "yarn run test:full",
     "eslint": "eslint src/**/*.ts",
     "git:addFiles": "git add .",
-    "postinstall": "opencollective"
+    "postinstall": "opencollective",
+    "prepublishOnly": "npm run build && tsc --project ./src/tsconfig.declarations.json"
   },
   "pre-commit": [
-    "build",
-    "git:addFiles"
+    "npm run build"
   ],
   "author": {
     "name": "Timofey Kachalov"

+ 13 - 0
src/tsconfig.declarations.json

@@ -0,0 +1,13 @@
+{
+  "extends": "./tsconfig.node.json",
+  "compilerOptions": {
+    "outDir": "../types",
+    "declaration": true,
+    "emitDeclarationOnly": true,
+    "skipLibCheck": true
+  },
+  "include": [
+    "../src",
+    "../index.ts"
+  ]
+}

部分文件因为文件数量过多而无法显示