From f2bb16a929aa033c4e7a07fc917b0b71cb7803e2 Mon Sep 17 00:00:00 2001 From: Bill D Date: Tue, 16 Mar 2021 14:34:34 +0400 Subject: [PATCH] automated node script for tsc library building --- get-verbs.js | 2 +- library-post-build.js | 18 ++++++++++++++++++ package.json | 6 ++++-- yarn.lock | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 library-post-build.js diff --git a/get-verbs.js b/get-verbs.js index 9fbd425..1a02fa2 100644 --- a/get-verbs.js +++ b/get-verbs.js @@ -11,7 +11,7 @@ const fetch = require("node-fetch"); const path = require("path"); const collectionPath = path.join(".", "verbs"); const verbTsFiles = fs.readdirSync(collectionPath); -const protoModels = require("./dictionary-models.js"); +const protoModels = require("./src/lib/dictionary-models.js"); const Pbf = require("pbf"); const allTsS = [...new Set(verbTsFiles.reduce((arr, fileName) => { diff --git a/library-post-build.js b/library-post-build.js new file mode 100644 index 0000000..8ba94de --- /dev/null +++ b/library-post-build.js @@ -0,0 +1,18 @@ +const pkg = require("./package.json"); +const glob = require("glob"); +const fs = require("fs-extra"); +const path = require("path"); + +fs.mkdir("dist/node_modules", {}, (err) => { + if (err) throw err; + const required = Object.keys(pkg.dependencies); + required.forEach((m) => { + fs.copySync(`node_modules/${m}`, `dist/node_modules/${m}`); + }); + glob("src/components/verb-info/*.svg", (err, files) => { + if (err) throw err; + files.forEach((file) => { + fs.copySync(file, `dist/components/verb-info/${path.basename(file)}`); + }); + }); +}); diff --git a/package.json b/package.json index bd29db7..ee02eca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "0.2.6", + "version": "0.2.7", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", @@ -40,6 +40,8 @@ "@types/react": "^17.0.3", "@types/react-dom": "^17.0.2", "bootstrap": "^4.6.0", + "fs-extra": "^9.1.0", + "glob": "^7.1.6", "node-fetch": "^2.6.1", "react": "^17.0.1", "react-bootstrap": "^1.5.1", @@ -61,7 +63,7 @@ "test": "react-scripts test", "eject": "react-scripts eject", "build-website": "node get-verbs.js && npm run build", - "build-library": "node get-verbs.js && rimraf dist && rimraf dist-cjs && tsc --project library-tsconfig.json && mkdir dist/node_modules && cp -r node_modules/classnames dist/node_modules && cp -r node_modules/pbf dist/node_modules && cp src/components/verb-info/*.svg dist/components/verb-info && rollup -c", + "build-library": "node get-verbs.js && rimraf dist && rimraf dist-cjs && tsc --project library-tsconfig.json && node library-post-build.js && rollup -c", "test-ci": "npm run test -- --watchAll=false" }, "eslintConfig": { diff --git a/yarn.lock b/yarn.lock index a228abd..88ca6e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5235,7 +5235,7 @@ fs-extra@^8.1.0: jsonfile "^4.0.0" universalify "^0.1.0" -fs-extra@^9.0.1: +fs-extra@^9.0.1, fs-extra@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==