From 6e1bb2d97eba50122be4a3881a670480cda099e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bu=CC=80i=20Vie=CC=A3=CC=82t=20Tha=CC=80nh?= Date: Mon, 22 Apr 2019 18:01:37 +0700 Subject: [PATCH] migrated to lerna & yarn workspaces --- .gitignore | 5 +- package.json | 17 +++-- packages/classapplier/package.json | 51 ++++++++++++++ packages/classapplier/src/index.ts | 4 +- packages/classapplier/src/types.d.ts | 14 ---- packages/classapplier/tsconfig.json | 10 +++ packages/core/package.json | 50 ++++++++++++++ packages/core/src/types.d.ts | 4 -- packages/core/tsconfig.json | 9 +++ packages/highlighter/package.json | 52 ++++++++++++++ packages/highlighter/src/index.ts | 6 +- packages/highlighter/src/types.d.ts | 11 --- packages/highlighter/tsconfig.json | 13 ++++ packages/selectionsaverestore/package.json | 51 ++++++++++++++ packages/selectionsaverestore/src/index.ts | 4 +- packages/selectionsaverestore/src/types.d.ts | 14 ---- packages/selectionsaverestore/tsconfig.json | 10 +++ packages/serializer/package.json | 51 ++++++++++++++ packages/serializer/src/index.ts | 4 +- packages/serializer/src/types.d.ts | 19 ----- packages/serializer/tsconfig.json | 10 +++ packages/tsconfig.base.json | 6 -- packages/util/package.json | 51 ++++++++++++++ packages/util/src/index.ts | 4 +- packages/util/src/types.d.ts | 7 -- packages/util/tsconfig.json | 10 +++ scripts/clean.ts | 21 ++++++ scripts/dist-prepare.ts | 73 -------------------- scripts/publish.ts | 14 ---- scripts/rollup.config.test.ts | 10 +-- scripts/rollup.config.ts | 14 ++-- scripts/tsc.ts | 58 ---------------- scripts/util.ts | 7 +- tsconfig.json | 14 ++-- yarn.lock | 51 +++++++++++++- 35 files changed, 485 insertions(+), 264 deletions(-) create mode 100644 packages/classapplier/package.json delete mode 100644 packages/classapplier/src/types.d.ts create mode 100644 packages/classapplier/tsconfig.json create mode 100644 packages/core/package.json delete mode 100644 packages/core/src/types.d.ts create mode 100644 packages/core/tsconfig.json create mode 100644 packages/highlighter/package.json delete mode 100644 packages/highlighter/src/types.d.ts create mode 100644 packages/highlighter/tsconfig.json create mode 100644 packages/selectionsaverestore/package.json delete mode 100644 packages/selectionsaverestore/src/types.d.ts create mode 100644 packages/selectionsaverestore/tsconfig.json create mode 100644 packages/serializer/package.json delete mode 100644 packages/serializer/src/types.d.ts create mode 100644 packages/serializer/tsconfig.json create mode 100644 packages/util/package.json delete mode 100644 packages/util/src/types.d.ts create mode 100644 packages/util/tsconfig.json create mode 100644 scripts/clean.ts delete mode 100644 scripts/dist-prepare.ts delete mode 100644 scripts/publish.ts delete mode 100644 scripts/tsc.ts diff --git a/.gitignore b/.gitignore index 99590512..1e805c28 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,7 @@ node_modules /tscOut/ /.rpt2_cache/ /lib/ -/src/*/tsconfig.json /scripts/*.js -/src/**/*.js *.js.map *.ts.map *.tsbuildinfo @@ -16,3 +14,6 @@ node_modules /test/*.d.ts !/test/typings.d.ts /test/qunit-ex.js* +/packages/*/lib/ +!/packages/*/lib/types/types.d.ts +yarn-error.log diff --git a/package.json b/package.json index a48dc561..5b420f63 100644 --- a/package.json +++ b/package.json @@ -39,20 +39,21 @@ }, "scripts": { "postinstall": "echo 'https://github.com/qunitjs/qunit/issues/1389' && patch -i qunit.patch node_modules/qunit/qunit/qunit.js", - "clean": "rimraf dist .rpt2_cache", "tsc:scripts": "tsc -b scripts/tsconfig.json", "watch:scripts": "tsc -b scripts/tsconfig.json --watch --pretty", - "dist-prepare": "node scripts/dist-prepare.js", - "tsc:src": "node $NODE_DEBUG_OPTION scripts/tsc.js -b", - "watch:tsc_src": "node scripts/tsc.js -b --watch --pretty", + "clean": "node scripts/clean.js && rimraf .rpt2_cache", + "tsc:es2018": "tsc -b", + "watch:tsc_es2018": "tsc -b --watch --pretty", + "tsc:es5": "lerna exec --stream --parallel -- ../../node_modules/.bin/tsc --outDir lib/esm5 --target es5", + "watch:tsc_es5": "lerna exec --stream --parallel -- ../../node_modules/.bin/tsc --outDir lib/esm5 --target es5 --watch --pretty", "rollup:src": "rollup -c scripts/rollup.config.js", "watch:rollup_src": "FORCE_COLOR=1 rollup -c scripts/rollup.config.js --watch", - "build:src": "npm-run-all tsc:src rollup:src", + "build:src": "npm-run-all tsc:es2018 tsc:es5 rollup:src", "build:test": "rollup -c scripts/rollup.config.test.js", "watch:test": "FORCE_COLOR=1 rollup -c scripts/rollup.config.test.js --watch", "build": "run-s tsc:scripts build:src build:test", - "prerelease": "run-s clean build dist-prepare", - "release": "node scripts/publish.js", + "prerelease": "TODO run-s clean build dist-prepare", + "release": "TODO node scripts/publish.js", "watch": "run-p -l watch:*", "test": "echo 'pls browse test/*.html for testing'" }, @@ -67,7 +68,9 @@ "devDependencies": { "@types/glob": "^7.1.1", "@types/qunit": "^2.5.4", + "@types/rimraf": "^2.0.2", "bowser": "^2.3.0", + "delete-empty": "^2.0.0", "glob": "^7.1.3", "lerna": "^3.13.3", "log4javascript": "^1.4.15", diff --git a/packages/classapplier/package.json b/packages/classapplier/package.json new file mode 100644 index 00000000..aee34ba5 --- /dev/null +++ b/packages/classapplier/package.json @@ -0,0 +1,51 @@ +{ + "name": "@rangy/classapplier", + "description": "A cross-browser DOM range and selection library", + "version": "2.1.0", + "author": { + "name": "Tim Down", + "email": "tim@timdown.co.uk", + "url": "http://timdown.co.uk/" + }, + "contributors": [ + { + "name": "Bui Viet Thanh", + "email": "thanhbv@sandinh.net", + "url": "https://github.com/ohze" + } + ], + "keywords": [ + "range", + "selection", + "caret", + "DOM" + ], + "homepage": "https://github.com/ohze/rangy", + "bugs": { + "url": "https://github.com/ohze/rangy/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/ohze/rangy.git" + }, + "main": "lib/bundles/index.umd.js", + "module": "lib/esm5/index.js", + "es2015": "lib/esm2015/index.js", + "typings": "lib/types/types.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "tsc -b ." + }, + "dependencies": { + "@rangy/core": "^2.1.0", + "core-js": "^3.0.1", + "tslib": "^1.9.3" + }, + "devDependencies": {} +} diff --git a/packages/classapplier/src/index.ts b/packages/classapplier/src/index.ts index b01ae7b5..48a24594 100644 --- a/packages/classapplier/src/index.ts +++ b/packages/classapplier/src/index.ts @@ -13,8 +13,8 @@ * Build date: %%build:date%% */ -import * as api from "rangy2"; -import {dom, Module} from "rangy2"; +import * as api from "@rangy/core"; +import {dom, Module} from "@rangy/core"; const DomPosition = dom.DomPosition, isHostMethod = api.util.isHostMethod; diff --git a/packages/classapplier/src/types.d.ts b/packages/classapplier/src/types.d.ts deleted file mode 100644 index 1531c381..00000000 --- a/packages/classapplier/src/types.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// this file will be copy to dist//index.d.ts when running scripts/tsc.ts -import * as rangy from "rangy2"; -export * from "./index"; -import * as m from "./index"; - -declare module "rangy2" { - type ClassApplier = m.ClassApplier; - const ClassApplier: typeof m.ClassApplier; - - type CssClassApplier = m.ClassApplier; - const CssClassApplier: typeof m.ClassApplier; - - const createClassApplier: typeof m.createClassApplier; -} diff --git a/packages/classapplier/tsconfig.json b/packages/classapplier/tsconfig.json new file mode 100644 index 00000000..57e73485 --- /dev/null +++ b/packages/classapplier/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "lib/types", + "outDir": "lib/esm2015", + "target": "es2018" + }, + "references": [{"path": "../core"}] +} \ No newline at end of file diff --git a/packages/core/package.json b/packages/core/package.json new file mode 100644 index 00000000..efa1e015 --- /dev/null +++ b/packages/core/package.json @@ -0,0 +1,50 @@ +{ + "name": "@rangy/core", + "description": "A cross-browser DOM range and selection library", + "version": "2.1.0", + "author": { + "name": "Tim Down", + "email": "tim@timdown.co.uk", + "url": "http://timdown.co.uk/" + }, + "contributors": [ + { + "name": "Bui Viet Thanh", + "email": "thanhbv@sandinh.net", + "url": "https://github.com/ohze" + } + ], + "keywords": [ + "range", + "selection", + "caret", + "DOM" + ], + "homepage": "https://github.com/ohze/rangy", + "bugs": { + "url": "https://github.com/ohze/rangy/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/ohze/rangy.git" + }, + "main": "lib/bundles/index.umd.js", + "module": "lib/esm5/index.js", + "es2015": "lib/esm2015/index.js", + "typings": "lib/types/types.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "tsc -b ." + }, + "dependencies": { + "core-js": "^3.0.1", + "tslib": "^1.9.3" + }, + "devDependencies": {} +} diff --git a/packages/core/src/types.d.ts b/packages/core/src/types.d.ts deleted file mode 100644 index 2ed32c02..00000000 --- a/packages/core/src/types.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -// this file will be copy to dist//index.d.ts when running scripts/tsc.ts -export * from "./index"; - -export as namespace rangy; diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json new file mode 100644 index 00000000..14b208f2 --- /dev/null +++ b/packages/core/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "lib/types", + "outDir": "lib/esm2015", + "target": "es2018" + } +} \ No newline at end of file diff --git a/packages/highlighter/package.json b/packages/highlighter/package.json new file mode 100644 index 00000000..cc793cf1 --- /dev/null +++ b/packages/highlighter/package.json @@ -0,0 +1,52 @@ +{ + "name": "@rangy/highlighter", + "description": "A cross-browser DOM range and selection library", + "version": "2.1.0", + "author": { + "name": "Tim Down", + "email": "tim@timdown.co.uk", + "url": "http://timdown.co.uk/" + }, + "contributors": [ + { + "name": "Bui Viet Thanh", + "email": "thanhbv@sandinh.net", + "url": "https://github.com/ohze" + } + ], + "keywords": [ + "range", + "selection", + "caret", + "DOM" + ], + "homepage": "https://github.com/ohze/rangy", + "bugs": { + "url": "https://github.com/ohze/rangy/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/ohze/rangy.git" + }, + "main": "lib/bundles/index.umd.js", + "module": "lib/esm5/index.js", + "es2015": "lib/esm2015/index.js", + "typings": "lib/types/types.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "tsc -b ." + }, + "dependencies": { + "@rangy/classapplier": "^2.1.0", + "@rangy/core": "^2.1.0", + "core-js": "^3.0.1", + "tslib": "^1.9.3" + }, + "devDependencies": {} +} diff --git a/packages/highlighter/src/index.ts b/packages/highlighter/src/index.ts index fa8b7de8..d4f63cc1 100644 --- a/packages/highlighter/src/index.ts +++ b/packages/highlighter/src/index.ts @@ -9,9 +9,9 @@ * Version: %%build:version%% * Build date: %%build:date%% */ -import * as api from "rangy2"; -import {WrappedRange, WrappedSelection, dom, RangyRangeEx} from "rangy2"; -import {ClassApplier} from "../classapplier"; +import * as api from "@rangy/core"; +import {WrappedRange, WrappedSelection, dom, RangyRangeEx} from "@rangy/core"; +import {ClassApplier} from "@rangy/classapplier"; const getBody = dom.getBody; // const module = new Module("Highlighter", ["ClassApplier"]); diff --git a/packages/highlighter/src/types.d.ts b/packages/highlighter/src/types.d.ts deleted file mode 100644 index 4c5aca9a..00000000 --- a/packages/highlighter/src/types.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// this file will be copy to dist//index.d.ts when running scripts/tsc.ts -import * as rangy from "rangy2"; -export * from "./index"; -import * as m from "./index"; - -declare module "rangy2" { - const registerHighlighterType: typeof m.registerHighlighterType; - const createHighlighter: typeof m.createHighlighter; - type Highlighter = m.Highlighter; - const Highlighter: typeof m.Highlighter; -} diff --git a/packages/highlighter/tsconfig.json b/packages/highlighter/tsconfig.json new file mode 100644 index 00000000..597298ee --- /dev/null +++ b/packages/highlighter/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "lib/types", + "outDir": "lib/esm2015", + "target": "es2018" + }, + "references": [ + {"path": "../core"}, + {"path": "../classapplier"} + ] +} \ No newline at end of file diff --git a/packages/selectionsaverestore/package.json b/packages/selectionsaverestore/package.json new file mode 100644 index 00000000..48a6c72b --- /dev/null +++ b/packages/selectionsaverestore/package.json @@ -0,0 +1,51 @@ +{ + "name": "@rangy/selectionsaverestore", + "description": "A cross-browser DOM range and selection library", + "version": "2.1.0", + "author": { + "name": "Tim Down", + "email": "tim@timdown.co.uk", + "url": "http://timdown.co.uk/" + }, + "contributors": [ + { + "name": "Bui Viet Thanh", + "email": "thanhbv@sandinh.net", + "url": "https://github.com/ohze" + } + ], + "keywords": [ + "range", + "selection", + "caret", + "DOM" + ], + "homepage": "https://github.com/ohze/rangy", + "bugs": { + "url": "https://github.com/ohze/rangy/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/ohze/rangy.git" + }, + "main": "lib/bundles/index.umd.js", + "module": "lib/esm5/index.js", + "es2015": "lib/esm2015/index.js", + "typings": "lib/types/types.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "tsc -b ." + }, + "dependencies": { + "@rangy/core": "^2.1.0", + "core-js": "^3.0.1", + "tslib": "^1.9.3" + }, + "devDependencies": {} +} diff --git a/packages/selectionsaverestore/src/index.ts b/packages/selectionsaverestore/src/index.ts index fc52a236..3860f277 100644 --- a/packages/selectionsaverestore/src/index.ts +++ b/packages/selectionsaverestore/src/index.ts @@ -13,8 +13,8 @@ * Build date: %%build:date%% */ -import * as api from "rangy2"; -import {Module, dom, features} from "rangy2"; +import * as api from "@rangy/core"; +import {Module, dom, features} from "@rangy/core"; const removeNode = dom.removeNode; diff --git a/packages/selectionsaverestore/src/types.d.ts b/packages/selectionsaverestore/src/types.d.ts deleted file mode 100644 index b493d94b..00000000 --- a/packages/selectionsaverestore/src/types.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as rangy from "rangy2"; -export * from "./index"; -import * as m from "./index"; - -declare module "rangy2" { - const saveRange: typeof m.saveRange; - const restoreRange: typeof m.restoreRange; - const saveRanges: typeof m.saveRanges; - const saveSelection: typeof m.saveSelection; - const restoreRanges: typeof m.restoreRanges; - const restoreSelection: typeof m.restoreSelection; - const removeMarkerElement: typeof m.removeMarkerElement; - const removeMarkers: typeof m.removeMarkers; -} diff --git a/packages/selectionsaverestore/tsconfig.json b/packages/selectionsaverestore/tsconfig.json new file mode 100644 index 00000000..57e73485 --- /dev/null +++ b/packages/selectionsaverestore/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "lib/types", + "outDir": "lib/esm2015", + "target": "es2018" + }, + "references": [{"path": "../core"}] +} \ No newline at end of file diff --git a/packages/serializer/package.json b/packages/serializer/package.json new file mode 100644 index 00000000..2e05d0a0 --- /dev/null +++ b/packages/serializer/package.json @@ -0,0 +1,51 @@ +{ + "name": "@rangy/serializer", + "description": "A cross-browser DOM range and selection library", + "version": "2.1.0", + "author": { + "name": "Tim Down", + "email": "tim@timdown.co.uk", + "url": "http://timdown.co.uk/" + }, + "contributors": [ + { + "name": "Bui Viet Thanh", + "email": "thanhbv@sandinh.net", + "url": "https://github.com/ohze" + } + ], + "keywords": [ + "range", + "selection", + "caret", + "DOM" + ], + "homepage": "https://github.com/ohze/rangy", + "bugs": { + "url": "https://github.com/ohze/rangy/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/ohze/rangy.git" + }, + "main": "lib/bundles/index.umd.js", + "module": "lib/esm5/index.js", + "es2015": "lib/esm2015/index.js", + "typings": "lib/types/types.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "tsc -b ." + }, + "dependencies": { + "@rangy/core": "^2.1.0", + "core-js": "^3.0.1", + "tslib": "^1.9.3" + }, + "devDependencies": {} +} diff --git a/packages/serializer/src/index.ts b/packages/serializer/src/index.ts index a6b28a47..77ae34ca 100644 --- a/packages/serializer/src/index.ts +++ b/packages/serializer/src/index.ts @@ -19,8 +19,8 @@ import {crc32} from "./crc32"; // don't directly import modules from ../core/ // (only import ../core/index) // otherwise rollup.config.js/ rangyModulesConfigs will failed! -import * as api from "rangy2"; -import {dom, Module} from "rangy2"; +import * as api from "@rangy/core"; +import {dom, Module} from "@rangy/core"; const module = new Module("Serializer", ["WrappedSelection"]); diff --git a/packages/serializer/src/types.d.ts b/packages/serializer/src/types.d.ts deleted file mode 100644 index 4a935bd0..00000000 --- a/packages/serializer/src/types.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// this file will be copy to dist//index.d.ts when running scripts/tsc.ts -import * as rangy from "rangy2"; -export * from "./index"; -import * as m from "./index"; - -declare module "rangy2" { - const nodeToInfoString: typeof m.nodeToInfoString; - const getElementChecksum: typeof m.getElementChecksum; - const serializePosition: typeof m.serializePosition; - const deserializePosition: typeof m.deserializePosition; - const serializeRange: typeof m.serializeRange; - const deserializeRange: typeof m.deserializeRange; - const canDeserializeRange: typeof m.canDeserializeRange; - const serializeSelection: typeof m.serializeSelection; - const deserializeSelection: typeof m.deserializeSelection; - const canDeserializeSelection: typeof m.canDeserializeSelection; - const restoreSelectionFromCookie: typeof m.restoreSelectionFromCookie; - const saveSelectionCookie: typeof m.saveSelectionCookie; -} diff --git a/packages/serializer/tsconfig.json b/packages/serializer/tsconfig.json new file mode 100644 index 00000000..57e73485 --- /dev/null +++ b/packages/serializer/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "lib/types", + "outDir": "lib/esm2015", + "target": "es2018" + }, + "references": [{"path": "../core"}] +} \ No newline at end of file diff --git a/packages/tsconfig.base.json b/packages/tsconfig.base.json index 0121b553..a6f8b123 100644 --- a/packages/tsconfig.base.json +++ b/packages/tsconfig.base.json @@ -14,12 +14,6 @@ "declaration": true, "declarationMap": true, "importHelpers": true, - "plugins": [ - { - "name": "typescript-tslint-plugin", - "alwaysShowRuleFailuresAsWarnings": false - } - ], "composite": true } } \ No newline at end of file diff --git a/packages/util/package.json b/packages/util/package.json new file mode 100644 index 00000000..6ddb96d4 --- /dev/null +++ b/packages/util/package.json @@ -0,0 +1,51 @@ +{ + "name": "@rangy/util", + "description": "A cross-browser DOM range and selection library", + "version": "2.1.0", + "author": { + "name": "Tim Down", + "email": "tim@timdown.co.uk", + "url": "http://timdown.co.uk/" + }, + "contributors": [ + { + "name": "Bui Viet Thanh", + "email": "thanhbv@sandinh.net", + "url": "https://github.com/ohze" + } + ], + "keywords": [ + "range", + "selection", + "caret", + "DOM" + ], + "homepage": "https://github.com/ohze/rangy", + "bugs": { + "url": "https://github.com/ohze/rangy/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/ohze/rangy.git" + }, + "main": "lib/bundles/index.umd.js", + "module": "lib/esm5/index.js", + "es2015": "lib/esm2015/index.js", + "typings": "lib/types/types.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "tsc -b ." + }, + "dependencies": { + "@rangy/core": "^2.1.0", + "core-js": "^3.0.1", + "tslib": "^1.9.3" + }, + "devDependencies": {} +} diff --git a/packages/util/src/index.ts b/packages/util/src/index.ts index 140877bf..a3f69945 100644 --- a/packages/util/src/index.ts +++ b/packages/util/src/index.ts @@ -12,12 +12,12 @@ * Version: %%build:version%% * Build date: %%build:date%% */ -import * as api from "rangy2"; +import * as api from "@rangy/core"; import { WrappedSelection as SelProto, DomRange as RangeProto, getNativeSelection -} from "rangy2"; +} from "@rangy/core"; // const module = new Module("Util", ["WrappedSelection"]); diff --git a/packages/util/src/types.d.ts b/packages/util/src/types.d.ts deleted file mode 100644 index a7485db2..00000000 --- a/packages/util/src/types.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// this file will be copy to dist//index.d.ts when running scripts/tsc.ts -import * as rangy from "rangy2"; -export * from "./index"; -import * as m from "./index"; - -declare module "rangy2" { -} diff --git a/packages/util/tsconfig.json b/packages/util/tsconfig.json new file mode 100644 index 00000000..57e73485 --- /dev/null +++ b/packages/util/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "lib/types", + "outDir": "lib/esm2015", + "target": "es2018" + }, + "references": [{"path": "../core"}] +} \ No newline at end of file diff --git a/scripts/clean.ts b/scripts/clean.ts new file mode 100644 index 00000000..e27973a7 --- /dev/null +++ b/scripts/clean.ts @@ -0,0 +1,21 @@ +import glob from 'glob'; +import util from 'util'; +import {projectRoot} from './util'; +import fs from 'fs'; +import deleteEmpty from 'delete-empty'; + +const g = util.promisify(glob); +const unlink = util.promisify(fs.unlink); + +async function main() { + const files = await g("packages/*/lib/**", { + cwd: projectRoot, + nodir: true, + ignore: "packages/*/lib/types/types.d.ts" + }); + await Promise.all(files.map(f => unlink(f))); + const dirs = await g("packages/*/lib/**/"); + await Promise.all(dirs.map(d => deleteEmpty(d))); +} + +main(); diff --git a/scripts/dist-prepare.ts b/scripts/dist-prepare.ts deleted file mode 100644 index b8665b50..00000000 --- a/scripts/dist-prepare.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { writeFileSync, copyFileSync, statSync, mkdirSync } from 'fs'; -import { resolve, basename } from 'path'; -import * as packageJson from '../package.json'; -import {modules, projectRoot} from "./util"; - -main(); - -function main() { - console.log('copy modules:', modules.join(', ')); - - modules.forEach(process); - - function process(name: string) { - const distPath = resolve(projectRoot, 'dist', name); - mkdirSync(distPath, {recursive: true}); - const distPackageJson = createDistPackageJson(packageJson, name); - - const cpFiles = ['README.md', 'CHANGELOG.md', 'LICENSE', '.npmignore'].map( - (file) => resolve(projectRoot, file) - ); - - cp(cpFiles, distPath); - - writeFileSync(resolve(distPath, 'package.json'), distPackageJson) - } -} - -function cp(source: string[] | string, target: string) { - const isDir = statSync(target).isDirectory(); - - if (isDir) { - if (!Array.isArray(source)) { - throw new Error( - 'if is directory you need to provide source as an array' - ) - } - - source.forEach((file) => - copyFileSync(file, resolve(target, basename(file))) - ); - - return - } - if (Array.isArray(source)) { - throw new Error( - 'if is not a directory you need to provide source as an string' - ) - } - - copyFileSync(source, target) -} - -function createDistPackageJson(packageConfig: typeof packageJson, name: string): string { - const { - devDependencies, - scripts, - // engines, - // config, - // husky, - // 'lint-staged': lintStaged, - ...json - } = packageConfig; - - if(name != 'core') { - Object.assign(json.dependencies, { - [json.name]: '^' + json.version - }); - - json.name = `rangy-${name}`; - } - - return JSON.stringify(json, null, 2) -} diff --git a/scripts/publish.ts b/scripts/publish.ts deleted file mode 100644 index a1fb989b..00000000 --- a/scripts/publish.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {spawnSync} from "child_process"; -import {modules, projectRoot} from "./util"; - -function publish(module: string) { - const args = ['yarn', ['publish', `dist/${module}`, '--non-interactive']]; - console.log(args.flat().join(' ')); - spawnSync('yarn', ['publish', `dist/${module}`, '--non-interactive'], { - stdio:'inherit', - cwd: projectRoot, - }); -} - -console.log('publishing modules: ' + modules.join(', ') + '...'); -modules.forEach(publish); diff --git a/scripts/rollup.config.test.ts b/scripts/rollup.config.test.ts index 54e9a82a..8e98cd67 100644 --- a/scripts/rollup.config.test.ts +++ b/scripts/rollup.config.test.ts @@ -7,7 +7,7 @@ import nodeResolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; import * as glob from 'glob'; import typescript from 'rollup-plugin-typescript2' -import {modules, projectRoot} from "./util"; +import {packages, projectRoot} from "./util"; import {resolve, join} from "path"; import {ModuleFormat, RollupOptions} from "rollup"; @@ -22,13 +22,13 @@ const plugins = [ ]; //all rangy modules are external dependencies to test code -const external = ['rangy2', ...modules.map(n => 'rangy-' + n)]; +const external = packages.map(n => '@rangy/' + n); //map all external dependencies to global name 'rangy' const globals = {}; external.forEach(n => Object.assign(globals, {[n]: 'rangy'})); -function iifeConfig(f: string, format: ModuleFormat = 'iife'): RollupOptions { +function config(f: string, format: ModuleFormat = 'iife'): RollupOptions { f = join(testDir, f); return { input: [f], @@ -47,8 +47,8 @@ function iifeConfig(f: string, format: ModuleFormat = 'iife'): RollupOptions { const configs = glob .sync('**/*.ts', {cwd: testDir}) .filter(f => !f.endsWith('.d.ts')) - .map(f => iifeConfig(f)); + .map(f => config(f)); // push amdTestExampleConfig -configs.push(iifeConfig("classapplier/index.test.ts", 'amd')); +configs.push(config("classapplier/index.test.ts", 'amd')); export default configs; diff --git a/scripts/rollup.config.ts b/scripts/rollup.config.ts index 84f12e91..db1cc11c 100644 --- a/scripts/rollup.config.ts +++ b/scripts/rollup.config.ts @@ -1,10 +1,10 @@ import sourceMaps from 'rollup-plugin-sourcemaps' import nodeResolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; -import * as pkg from '../package.json'; +import * as lerna from '../lerna.json'; import replace from 'rollup-plugin-re'; import {RollupOptions} from "rollup"; -import {modules, projectRoot} from "./util"; +import {packages, packagesDir} from "./util"; import {resolve} from "path"; import { uglify } from 'rollup-plugin-uglify' import { terser } from 'rollup-plugin-terser' @@ -14,7 +14,7 @@ const buildVars = (function() { const month = "January,February,March,April,May,June,July,August,September,October,November,December" .split(",")[date.getMonth()]; return { - "%%build:version%%": pkg.version, + "%%build:version%%": lerna.version, "%%build:date%%": date.getDate() + " " + month + " " + date.getFullYear(), "%%build:year%%,": date.getFullYear() + ',' }; @@ -48,10 +48,10 @@ function outputFile(f: string, isProd: boolean) { function configsFor(module: string, isProd: boolean): RollupOptions[] { // const tsconfig = await import(`${srcDir}/${name}/tsconfig.json`); // const outDir = tsconfig.compilerOptions.outDir; - const d = resolve(projectRoot, 'dist', module); + const d = resolve(packagesDir, module, 'lib'); const isRangyModule = module !== 'core'; // Indicate here external modules you don't wanna include in your bundle - const external = isRangyModule? ['rangy2'] : []; + const external = isRangyModule? ['@rangy/core'] : []; return [ { input: [`${d}/esm5/index.js`], output: { @@ -60,7 +60,7 @@ function configsFor(module: string, isProd: boolean): RollupOptions[] { name: 'rangy', sourcemap: true, extend: isRangyModule, - globals: { rangy2: "rangy" } + globals: { "@rangy/core": "rangy" } }, inlineDynamicImports: true, external, @@ -80,7 +80,7 @@ function configsFor(module: string, isProd: boolean): RollupOptions[] { ] } -const configs = modules.flatMap(m => [ +const configs = packages.flatMap(m => [ ...configsFor(m, false), ...configsFor(m, true) ]); diff --git a/scripts/tsc.ts b/scripts/tsc.ts deleted file mode 100644 index 26d2963f..00000000 --- a/scripts/tsc.ts +++ /dev/null @@ -1,58 +0,0 @@ -import {writeFileSync, copyFileSync} from "fs"; -import {resolve} from "path"; -import {srcDir, modules, distDir} from "./util"; -import {spawnSync} from "child_process"; - -function writeTsConfig(name: string, es: boolean) { - const target = es? "es2018" : "es5"; - const outDir = es? "esm2015" : "esm5"; - const c = { - extends: "../tsconfig.base.json", - compilerOptions: { - declarationDir: `../../dist/${name}/types`, - outDir: `../../dist/${name}/${outDir}`, - target, - baseUrl: ".", - paths: { - rangy2: ["../core/index"] - } - } - }; - - if (name !== 'core') { - Object.assign(c, { - references: [{ path: "../core" }] - }); - } - - writeFileSync( - resolve(srcDir, name, 'tsconfig.json'), - JSON.stringify(c, null, 2) - ); -} - -function tsc(es: boolean): boolean { - modules.forEach(n => writeTsConfig(n, es)); - const args = process.argv.slice(2); //argv[0] is 'node', argv[1] is this script (scripts/tsc.js) - console.log(`$ tsc ${args.join(' ')} #es=${es}`); - const r = spawnSync('tsc', args, { - stdio:'inherit', - cwd: srcDir, - }); - return r.status === 0; -} - -function main() { - for(const es of [false, true]) { - const success = tsc(es); - if (!success) break; - } - - modules.forEach(m => { - copyFileSync(resolve(srcDir, m, 'types.d.ts'), resolve(distDir, m, 'types/types.d.ts')); - }); -} - -// usage: node [options] scripts/tsc.js [tsc arguments] -// note: tsc will run in cwd: srcDir -main(); diff --git a/scripts/util.ts b/scripts/util.ts index fb329743..8b3c6d57 100644 --- a/scripts/util.ts +++ b/scripts/util.ts @@ -2,10 +2,9 @@ import {join, resolve} from "path"; import {readdirSync, statSync} from "fs"; export const projectRoot = resolve(__dirname, '..'); -export const srcDir = resolve(projectRoot, 'src'); -export const distDir = resolve(projectRoot, 'dist'); +export const packagesDir = resolve(projectRoot, 'packages'); //['core', 'classapplier',..] -export const modules = readdirSync(srcDir) - .filter(n => statSync(join(srcDir, n)).isDirectory()); +export const packages = readdirSync(packagesDir) + .filter(n => statSync(join(packagesDir, n)).isDirectory()); diff --git a/tsconfig.json b/tsconfig.json index aa442670..f6f59322 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,12 +3,12 @@ "composite": true }, "references": [ - { "path": "./core"}, - { "path": "./classapplier"}, - { "path": "./highlighter"}, - { "path": "./selectionsaverestore"}, - { "path": "./serializer"}, - { "path": "./util"} + { "path": "packages/core"}, + { "path": "packages/classapplier"}, + { "path": "packages/highlighter"}, + { "path": "packages/selectionsaverestore"}, + { "path": "packages/serializer"}, + { "path": "packages/util"} ], - "include": [] + "files": [] } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index af1ad273..72b790a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -714,7 +714,7 @@ resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== -"@types/glob@^7.1.1": +"@types/glob@*", "@types/glob@^7.1.1": version "7.1.1" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" integrity sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w== @@ -745,6 +745,14 @@ dependencies: "@types/node" "*" +"@types/rimraf@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.2.tgz#7f0fc3cf0ff0ad2a99bb723ae1764f30acaf8b6e" + integrity sha512-Hm/bnWq0TCy7jmjeN5bKYij9vw5GrDFWME4IuxV08278NtU/VdGbzsBohcCUJ7+QMqmUq5hpRKB39HeQWJjztQ== + dependencies: + "@types/glob" "*" + "@types/node" "*" + JSONStream@^1.0.4, JSONStream@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -792,6 +800,13 @@ ansi-escapes@^3.2.0: resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== +ansi-green@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ansi-green/-/ansi-green-0.1.1.tgz#8a5d9a979e458d57c40e33580b37390b8e10d0f7" + integrity sha1-il2al55FjVfEDjNYCzc5C44Q0Pc= + dependencies: + ansi-wrap "0.1.0" + ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -814,6 +829,11 @@ ansi-styles@^3.2.1: dependencies: color-convert "^1.9.0" +ansi-wrap@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" + integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= + aproba@^1.0.3, aproba@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -1602,6 +1622,15 @@ delegates@^1.0.0: resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= +delete-empty@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/delete-empty/-/delete-empty-2.0.0.tgz#dcf7c4f93a98445119acd57b137d13e7af78fa39" + integrity sha512-voZ8OiMkVR9MOTTHZ5P0DaMDtIW6xEbXZeADp6U8uwxIJFhs2hRwyIlUZIs5hR4YIp9VYBURqZrV6Yz0ozhVpg== + dependencies: + log-ok "^0.1.1" + relative "^3.0.2" + rimraf "^2.6.2" + deprecation@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-1.0.1.tgz#2df79b79005752180816b7b6e079cbd80490d711" @@ -2861,6 +2890,14 @@ lodash@^4.17.11, lodash@^4.17.5, lodash@^4.2.1: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== +log-ok@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/log-ok/-/log-ok-0.1.1.tgz#bea3dd36acd0b8a7240d78736b5b97c65444a334" + integrity sha1-vqPdNqzQuKckDXhza1uXxlREozQ= + dependencies: + ansi-green "^0.1.1" + success-symbol "^0.1.0" + log4javascript@^1.4.15: version "1.4.15" resolved "https://registry.yarnpkg.com/log4javascript/-/log4javascript-1.4.15.tgz#85ac62e946b024c6b256216084e10601d5630604" @@ -3974,6 +4011,13 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" +relative@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/relative/-/relative-3.0.2.tgz#0dcd8ec54a5d35a3c15e104503d65375b5a5367f" + integrity sha1-Dc2OxUpdNaPBXhBFA9ZTdbWlNn8= + dependencies: + isobject "^2.0.0" + repeat-element@^1.1.2: version "1.1.3" resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" @@ -4590,6 +4634,11 @@ strong-log-transformer@^2.0.0: minimist "^1.2.0" through "^2.3.4" +success-symbol@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/success-symbol/-/success-symbol-0.1.0.tgz#24022e486f3bf1cdca094283b769c472d3b72897" + integrity sha1-JAIuSG878c3KCUKDt2nEctO3KJc= + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"