Skip to content

Commit

Permalink
Use generate codicon.css with embedded TTF instead of imported one
Browse files Browse the repository at this point in the history
- This removes the need to have codicon as depedency to the sprotty core
- Replace rimraf wih shx
- Generated file contains license links
  • Loading branch information
kaisalmen committed Nov 28, 2022
1 parent d9b542a commit 622fd7a
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"publish:next": "SHA=$(git rev-parse --short HEAD) && lerna publish preminor --exact --canary --preid next.${SHA} --dist-tag next --no-git-reset --no-git-tag-version --no-push --ignore-scripts --yes --no-verify-access"
},
"devDependencies": {
"lerna": "^4.0.0"
"lerna": "^4.0.0",
"shx": "^0.3.4"
},
"workspaces": [
"packages/*",
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-elk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@
"jenkins-mocha": "^8.0.0",
"mocha": "^7.2.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"ts-node": "^10.4.0",
"typescript": "~4.8.4"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib artifacts",
"clean": "shx rm -fr lib artifacts",
"build": "tsc -p ./tsconfig.json && yarn run lint",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\"",
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-no-null": "^1.0.2",
"mocha": "^7.2.0",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"typescript": "~4.8.4"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib artifacts",
"clean": "shx rm -fr lib artifacts",
"build": "tsc -p ./tsconfig.json && yarn run lint",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\"",
Expand Down
1 change: 1 addition & 0 deletions packages/sprotty/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/lib/
/artifacts/
/css/generated
34 changes: 34 additions & 0 deletions packages/sprotty/build/src/buildCodicon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');

function transformCodicon() {
fs.readFile('../../node_modules/@vscode/codicons/dist/codicon.css', 'utf8', (err, cssData) => {
if (err) {
console.error(err);
return;
}

if (!fs.existsSync('./css/generated')) {
fs.mkdirSync('./css/generated');
}

fs.readFile('../../node_modules/@vscode/codicons/dist/codicon.ttf', 'base64', (errTtf, dataTtf) => {
if (errTtf) {
console.error(errTtf);
return;
}
const ttfData = `data:font/ttf;base64,${dataTtf}`;
let alteredCssData = cssData.replace(/\"\.\/codicon\.ttf.*\"/gi, ttfData);
const licRef = `/* See license here:
* https://github.com/microsoft/vscode-codicons/blob/main/LICENSE-CODE
* https://github.com/microsoft/vscode-codicons/blob/main/LICENSE
*/
@font-face {`
alteredCssData = alteredCssData.replace('@font-face {', licRef);

fs.writeFileSync('./css/generated/codicon.css', alteredCssData);
});
});
}

transformCodicon();
9 changes: 5 additions & 4 deletions packages/sprotty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"directory": "packages/sprotty"
},
"dependencies": {
"@vscode/codicons": "^0.0.25",
"autocompleter": "^5.1.0",
"file-saver": "^2.0.2",
"inversify": "^5.1.1",
Expand All @@ -65,8 +64,10 @@
"@types/file-saver": "^2.0.3",
"@types/jsdom": "^16.2.13",
"@types/mocha": "^7.0.2",
"@types/node": "16.18.3",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"@vscode/codicons": "^0.0.32",
"chai": "^4.3.6",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -76,7 +77,6 @@
"jsdom": "^18.0.1",
"mocha": "^10.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"semver": "^7.3.7",
"snabbdom-to-html": "^7.0.0",
"ts-mocha": "^10.0.0",
Expand All @@ -85,8 +85,9 @@
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib artifacts",
"build": "tsc -p ./tsconfig.json && yarn run lint",
"clean": "shx rm -fr lib artifacts css/generated",
"build:generate": "node ./build/src/buildCodicon.js",
"build": "yarn run build:generate && tsc -p ./tsconfig.json && yarn run lint",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*|test-helper.ts)\"",
"test:cli": "ts-mocha \"./src/**/*.spec.?(ts|tsx)\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/sprotty/src/features/command-palette/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import '@vscode/codicons/dist/codicon.css';
import '../../../css/generated/codicon.css';
import { ContainerModule } from "inversify";
import { TYPES } from "../../base/types";
import { CommandPaletteActionProviderRegistry } from "./action-providers";
Expand Down
5 changes: 4 additions & 1 deletion packages/sprotty/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"src"
],
"exclude": [
"**/*.spec.ts", "**/*.spec.tsx", "src/utils/test-helper.ts"
"build",
"**/*.spec.ts",
"**/*.spec.tsx",
"src/utils/test-helper.ts"
]
}
28 changes: 23 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==

"@types/[email protected]":
version "16.18.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.3.tgz#d7f7ba828ad9e540270f01ce00d391c54e6e0abc"
integrity sha512-jh6m0QUhIRcZpNv7Z/rpN+ZWXOicUUQbSoWks7Htkbb9IjFQj4kzcX/xFCkjstCj5flMsN8FiSvt+q+Tcs4Llg==

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
Expand Down Expand Up @@ -1546,10 +1551,10 @@
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==

"@vscode/codicons@^0.0.25":
version "0.0.25"
resolved "https://registry.yarnpkg.com/@vscode/codicons/-/codicons-0.0.25.tgz#4ebc3e2c9e707ac46aea0becceda79f7738c647c"
integrity sha512-uqPhTdADjwoCh5Ufbv0M6TZiiP2mqbfJVB4grhVx1k+YeP03LDMOHBWPsNwGKn4/0S5Mq9o1w1GeftvR031Gzg==
"@vscode/codicons@^0.0.32":
version "0.0.32"
resolved "https://registry.yarnpkg.com/@vscode/codicons/-/codicons-0.0.32.tgz#9e27de90d509c69762b073719ba3bf46c3cd2530"
integrity sha512-3lgSTWhAzzWN/EPURoY4ZDBEA80OPmnaknNujA3qnI4Iu7AONWd9xF3iE4L+4prIe8E3TUnLQ4pxoaFTEEZNwg==

"@webassemblyjs/[email protected]":
version "1.11.1"
Expand Down Expand Up @@ -5117,6 +5122,11 @@ minimist@^1.2.0, minimist@^1.2.5:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==

minimist@^1.2.3:
version "1.2.7"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==

minipass-collect@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/minipass-collect/-/minipass-collect-1.0.2.tgz#22b813bf745dc6edba2576b940022ad6edc8c617"
Expand Down Expand Up @@ -6778,7 +6788,7 @@ shell-escape@^0.2.0:
resolved "https://registry.yarnpkg.com/shell-escape/-/shell-escape-0.2.0.tgz#68fd025eb0490b4f567a027f0bf22480b5f84133"
integrity sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=

shelljs@^0.8.3:
shelljs@^0.8.3, shelljs@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c"
integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==
Expand All @@ -6787,6 +6797,14 @@ shelljs@^0.8.3:
interpret "^1.0.0"
rechoir "^0.6.2"

shx@^0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/shx/-/shx-0.3.4.tgz#74289230b4b663979167f94e1935901406e40f02"
integrity sha512-N6A9MLVqjxZYcVn8hLmtneQWIJtp8IKzMP4eMnx+nqkvXoqinUPCbUFLp2UcWTEIUONhlk0ewxr/jaVGlc+J+g==
dependencies:
minimist "^1.2.3"
shelljs "^0.8.5"

side-channel@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
Expand Down

0 comments on commit 622fd7a

Please sign in to comment.