Selaa lähdekoodia

Adopt monaco-plugin-helpers

Alex Dima 7 vuotta sitten
vanhempi
commit
a8741f55a9
6 muutettua tiedostoa jossa 13 lisäystä ja 113 poistoa
  1. 9 0
      package-lock.json
  2. 2 1
      package.json
  3. 2 2
      scripts/bundle.js
  4. 0 30
      scripts/copy.js
  5. 0 52
      scripts/git.js
  6. 0 28
      scripts/rmdir.js

+ 9 - 0
package-lock.json

@@ -645,6 +645,15 @@
       "integrity": "sha512-zbi+FI4Bm1B48AvAVjir0XUJlH85ZyFHaBcXvZjfy+mui8VaE7Run2ai/l9cvb6oqzTKQwg/UpYDu0BWyB8K5w==",
       "dev": true
     },
+    "monaco-plugin-helpers": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.2.tgz",
+      "integrity": "sha512-7kUx8dtd5qVNVgUARBRhnM8oftPglYwlINfigC4yGUiuzqtIN22u1tly8umiOCIPR0eFiBLjt6aN23oZh2QJgg==",
+      "dev": true,
+      "requires": {
+        "typescript": "2.7.2"
+      }
+    },
     "ms": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",

+ 2 - 1
package.json

@@ -3,7 +3,7 @@
   "version": "0.9.0",
   "description": "Bundle of many languages for the Monaco Editor.",
   "scripts": {
-    "compile": "node ./scripts/rmdir ./release && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
+    "compile": "mrmdir ./release && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
     "watch": "tsc -p ./src --watch",
     "test": "mocha",
     "prepublish": "npm run compile && node ./scripts/bundle"
@@ -21,6 +21,7 @@
     "jsdom-no-contextify": "^3.1.0",
     "mocha": "^3.4.2",
     "monaco-editor-core": "0.11.1",
+    "monaco-plugin-helpers": "^1.0.2",
     "requirejs": "^2.3.5",
     "typescript": "2.7.2",
     "uglify-js": "^3.3.14"

+ 2 - 2
scripts/bundle.js

@@ -2,11 +2,11 @@ const requirejs = require('requirejs');
 const path = require('path');
 const fs = require('fs');
 const UglifyJS = require("uglify-js");
-const git = require('./git');
+const helpers = require('monaco-plugin-helpers');
 
 const REPO_ROOT = path.resolve(__dirname, '..');
 
-const sha1 = git.getGitVersion(REPO_ROOT);
+const sha1 = helpers.getGitVersion(REPO_ROOT);
 const semver = require('../package.json').version;
 const headerVersion = semver + '(' + sha1 + ')';
 

+ 0 - 30
scripts/copy.js

@@ -1,30 +0,0 @@
-/*---------------------------------------------------------------------------------------------
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *  Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-
-const fs = require('fs');
-const path = require('path');
-
-const source = path.join(process.cwd(), process.argv[2]);
-const destination = path.join(process.cwd(), process.argv[3]);
-
-// ensure target dir
-(function () {
-	let dirs = [];
-	let dirname = path.dirname(destination);
-	while (dirname !== process.cwd()) {
-		dirs.push(dirname);
-		dirname = path.dirname(dirname);
-	}
-
-	dirs.reverse();
-
-	dirs.forEach((dir) => {
-		try { fs.mkdirSync(dir); } catch (err) { }
-	})
-})();
-
-fs.writeFileSync(destination, fs.readFileSync(source));
-
-console.log(`Copied ${process.argv[2]} to ${process.argv[3]}`);

+ 0 - 52
scripts/git.js

@@ -1,52 +0,0 @@
-const path = require('path');
-const fs = require('fs');
-
-exports.getGitVersion = function(repo) {
-	var git = path.join(repo, '.git');
-	var headPath = path.join(git, 'HEAD');
-	var head;
-
-	try {
-		head = fs.readFileSync(headPath, 'utf8').trim();
-	} catch (e) {
-		return void 0;
-	}
-
-	if (/^[0-9a-f]{40}$/i.test(head)) {
-		return head;
-	}
-
-	var refMatch = /^ref: (.*)$/.exec(head);
-
-	if (!refMatch) {
-		return void 0;
-	}
-
-	var ref = refMatch[1];
-	var refPath = path.join(git, ref);
-
-	try {
-		return fs.readFileSync(refPath, 'utf8').trim();
-	} catch (e) {
-		// noop
-	}
-
-	var packedRefsPath = path.join(git, 'packed-refs');
-	var refsRaw;
-
-	try {
-		refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
-	} catch (e) {
-		return void 0;
-	}
-
-	var refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
-	var refsMatch;
-	var refs = {};
-
-	while (refsMatch = refsRegex.exec(refsRaw)) {
-		refs[refsMatch[2]] = refsMatch[1];
-	}
-
-	return refs[ref];
-};

+ 0 - 28
scripts/rmdir.js

@@ -1,28 +0,0 @@
-/*---------------------------------------------------------------------------------------------
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *  Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-
-const fs = require('fs');
-const path = require('path');
-
-const target = path.join(process.cwd(), process.argv[2]);
-if (fs.existsSync(target)) {
-	rmDir(target);
-}
-console.log(`Deleted ${process.argv[2]}`);
-
-function rmDir(dirPath) {
-	let entries = fs.readdirSync(dirPath);
-	if (entries.length > 0) {
-		for (var i = 0; i < entries.length; i++) {
-			var filePath = path.join(dirPath, entries[i]);
-			if (fs.statSync(filePath).isFile()) {
-				fs.unlinkSync(filePath);
-			} else {
-				rmDir(filePath);
-			}
-		}
-	}
-	fs.rmdirSync(dirPath);
-}