Skip to content

Commit c5f9496

Browse files
authored
Monorepo rc (IBM#577)
* feat: changes * feat: generate zip * feat: add workspaces * add private to package.json * feat: fill packages * add lerna * feat:change build to support lerna * feat: cleanup * remove unused * feat: add plex sans tc and few fixes * feat: Plex Math Updated build script to support limited weights * fix: add missing Chinese unicode file * change version and remove tags * feat: first pass * server test * fix: range for special cases * feat: remove folders from zip * generate default and all css * zero version for plex
1 parent c49422d commit c5f9496

File tree

15,301 files changed

+62463
-3836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

15,301 files changed

+62463
-3836
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ zip
1111
.idea
1212
dist
1313
/deploy-preview
14+
/public
1415
/tmp
1516
.env
17+
/.nx
1618

1719
# Source files
1820
# https://github.com/IBM/plex/issues/554
@@ -23,4 +25,8 @@ dist
2325
*.glyphs
2426
*.vfb
2527
*.designspace
26-
*.ufo
28+
*.ufo
29+
30+
# Packages
31+
packages/*/css
32+
packages/*/scss

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
20.0.0

gulp-tasks/build/deploy-preview.js

Lines changed: 148 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,118 @@
1111

1212
const gulp = require('gulp');
1313
const config = require('../config');
14+
const { globSync } = require('glob');
15+
const inject = require('gulp-inject');
16+
const replace = require('gulp-replace');
17+
18+
const _LIST_PACKAGES = [];
19+
20+
/**
21+
* List packages with output CSS
22+
*/
23+
function _listPackages() {
24+
25+
const listPackages = globSync(`packages/**/${config.cssSrc}`);
26+
27+
listPackages.length && listPackages.forEach(( path ) => {
28+
29+
const [, family] = path.split("/");
30+
31+
_LIST_PACKAGES.push({
32+
family,
33+
path,
34+
cssPath: `assets/${family}/${config.cssSrc}/ibm-${family}.css`
35+
});
36+
});
37+
}
1438

1539
/**
16-
* Copies test file to the deploy-preview folder
40+
* Transform family name map
41+
*/
42+
const _transformFamilyMap = {
43+
jp: "JP",
44+
kr: "KR",
45+
tc: "TC"
46+
}
47+
48+
function _transformFamilyName(family) {
49+
50+
return "IBM " + family.split("-").map((part) => {
51+
52+
return _transformFamilyMap[part] ? _transformFamilyMap[part] : part.charAt(0).toUpperCase() + part.slice(1);
53+
54+
}).join(" ");
55+
}
56+
57+
/**
58+
* Copies test file to the public folder
1759
*
1860
* @returns {*} gulp stream
1961
*/
2062
function _copyTest() {
63+
64+
_listPackages();
65+
2166
return gulp
22-
.src([config.testSrc])
67+
.src([config.testSrc + "/index.html"])
68+
.pipe(gulp.dest(config.deployPreviewPath));
69+
}
70+
71+
/**
72+
* Injects used CSS files into public index file
73+
*
74+
* @returns {*} gulp stream
75+
*/
76+
function _injectHtml() {
77+
78+
console.log("Inject html");
79+
80+
const injectCss = [];
81+
const injectStyle = [];
82+
const injectOptions = [
83+
`<option value="select" selected>Select family</option>`
84+
];
85+
86+
_LIST_PACKAGES.forEach(({ family, cssPath }) => {
87+
88+
injectCss.push(`${config.deployPreviewPath}/${cssPath}`);
89+
90+
injectStyle.push(`div[data-family="${family}"] { display: initial; }`);
91+
92+
const transformedFamily = _transformFamilyName(family);
93+
94+
injectOptions.push(`<option value="${transformedFamily}">${transformedFamily}</option>`)
95+
});
96+
97+
const target = gulp.src(`${config.deployPreviewPath}/index.html`);
98+
99+
return target
100+
.pipe(inject(
101+
gulp.src(injectCss, { read: false }), {
102+
transform: function(filepath) {
103+
104+
return `<link rel="stylesheet" href="${filepath.replace("/public/", "")}" />`;
105+
}
106+
}
107+
))
108+
.pipe(inject(
109+
gulp.src(config.testSrc + "/inject.txt", { ready: false }), {
110+
starttag: '<!-- inject:style -->',
111+
transform: function() {
112+
113+
return `<style>\n${injectStyle.join('\n')}\n</style>`;
114+
}
115+
}
116+
))
117+
.pipe(inject(
118+
gulp.src(config.testSrc + "/inject.txt", { ready: false }), {
119+
starttag: '<!-- inject:options -->',
120+
transform: function() {
121+
122+
return injectOptions.join('\n');
123+
}
124+
}
125+
))
23126
.pipe(gulp.dest(config.deployPreviewPath));
24127
}
25128

@@ -28,24 +131,56 @@ function _copyTest() {
28131
*
29132
* @returns {*} gulp stream
30133
*/
31-
function _copyCss() {
32-
return gulp
33-
.src([`${config.cssSrc}/**/*`])
34-
.pipe(gulp.dest(config.deployPreviewCSSPath));
134+
function _copyCss(done) {
135+
136+
console.log("Copy css");
137+
138+
const tasks = _LIST_PACKAGES.map(({ path, family }) => {
139+
140+
return () => gulp
141+
.src([path + "/*.*", "!" + path + "/*.min.*"])
142+
.pipe(replace(/local\(.*?\),/gm, ""))
143+
.pipe(gulp.dest([`${config.deployPreviewAssets}/${family}/${config.cssSrc}`]));
144+
});
145+
146+
return gulp.series(...tasks, (seriesDone) => {
147+
seriesDone();
148+
done();
149+
})();
35150
}
36151

37152
/**
38153
* Copies font files to the dist folder
39154
*
40155
* @returns {*} gulp stream
41156
*/
42-
function _copyFonts() {
157+
function _copyFonts(done) {
158+
159+
console.log("Copy fonts");
160+
161+
const tasks = _LIST_PACKAGES.map(({ path, family }) => {
162+
163+
return () => gulp
164+
.src([`packages/${family}/fonts/**/*.*`])
165+
.pipe(gulp.dest([`${config.deployPreviewAssets}/${family}/fonts`]));
166+
});
167+
168+
return gulp.series(...tasks, (seriesDone) => {
169+
seriesDone();
170+
done();
171+
})();
172+
}
173+
174+
/**
175+
* Copies preview node file to the public folder
176+
*
177+
* @returns {*} gulp stream
178+
*/
179+
function _copyPreview() {
180+
43181
return gulp
44-
.src(['IBM-Plex-*/fonts/**/*.*'])
45-
.pipe(gulp.dest(config.deployPreviewFontsPath));
182+
.src(["scripts/preview.js"])
183+
.pipe(gulp.dest(config.deployPreviewPath));
46184
}
47185

48-
gulp.task('build:deploy-preview:test', _copyTest);
49-
gulp.task('build:deploy-preview:css', _copyCss);
50-
gulp.task('build:deploy-preview:fonts', _copyFonts);
51-
gulp.task('build:deploy-preview', gulp.parallel('build:deploy-preview:test','build:deploy-preview:css','build:deploy-preview:fonts'));
186+
gulp.task('build:deploy-preview', gulp.series(_copyTest, _copyFonts, _copyCss, _injectHtml, _copyPreview));

gulp-tasks/clean.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

gulp-tasks/config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
module.exports = {
1111
cssSrc: 'css',
12-
testSrc: 'test/*.*',
13-
deployPreviewPath: 'deploy-preview',
14-
deployPreviewCSSPath: 'deploy-preview/assets/css',
15-
deployPreviewFontsPath: 'deploy-preview/assets',
12+
testSrc: 'test',
13+
deployPreviewPath: 'public',
14+
deployPreviewAssets: 'public/assets',
1615
};

gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
'use strict';
1111

1212
require('./gulp-tasks/build');
13-
require('./gulp-tasks/clean');
1413

1514
process.once('SIGINT', () => {
1615
process.exit(0);

lerna.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "independent",
3+
"npmClient": "yarn",
4+
"command": {
5+
"version": {
6+
"message": "chore(release): %s"
7+
}
8+
},
9+
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
10+
}

package.json

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@ibm/plex",
3+
"private": true,
34
"description": "The package of IBM’s typeface, IBM Plex",
4-
"version": "6.4.0",
5+
"version": "0.0.0",
56
"repository": "https://github.com/ibm/plex.git",
67
"license": "OFL-1.1",
78
"keywords": [
@@ -11,59 +12,49 @@
1112
"url": "https://github.com/ibm/plex/issues"
1213
},
1314
"files": [
14-
"css",
15-
"variants",
16-
"examples",
17-
"scss",
18-
"IBM-Plex-*/**/woff2",
19-
"IBM-Plex-*/**/woff",
20-
"!IBM-Plex-Sans-KR/fonts/hinted/**/woff2",
21-
"!IBM-Plex-Sans-KR/fonts/hinted/**/woff",
22-
"!IBM-Plex-Sans-JP/fonts/hinted/**/woff2",
23-
"!IBM-Plex-Sans-JP/fonts/hinted/**/woff",
2415
"telemetry.yml"
2516
],
17+
"workspaces": [
18+
"packages/*"
19+
],
2620
"scripts": {
27-
"clean": "rimraf css scss deploy-preview",
28-
"build": "yarn clean && yarn build:scss && yarn build:css && yarn build:deploy-preview",
29-
"build:zip": "yarn build && node ./scripts/prepare-zip.js && sh scripts/zip.sh",
21+
"clean": "rimraf public zip dist",
22+
"clean:family": "node ./scripts/clean.js",
23+
"build": "yarn clean:family && yarn build:scss && yarn build:css",
24+
"build:zip": "rimraf zip && yarn build && node ./scripts/prepare-zip.js && sh scripts/zip.sh && node ./scripts/clean-zip.js",
3025
"build:css": "node ./scripts/compile-css.js",
3126
"build:scss": "node ./scripts/generate-scss.js",
3227
"build:deploy-preview": "gulp build:deploy-preview",
33-
"test": "parcel serve ./deploy-preview/index.html",
28+
"unicodes": "node ./scripts/parse-unicodes.js",
29+
"preview": "rimraf public dist && yarn build:deploy-preview && node ./public/preview.js",
3430
"postinstall": "ibmtelemetry --config=telemetry.yml",
3531
"precommit": "lint-staged",
3632
"prettier": "prettier --write \"**/*.{scss}\"",
3733
"prepare": "husky install && yarn build",
38-
"test:e2e:local": "start-server-and-test 'http-server -c-1 deploy-preview --silent' 8080 'percy exec --config cypress/.percy.json -- cypress run --config-file cypress/cypress.json'",
39-
"test:e2e:local:no-percy": "start-server-and-test 'http-server -c-1 deploy-preview --silent' 8080 'cypress run --config-file cypress/cypress.json'"
34+
"test:e2e:local": "start-server-and-test 'http-server -c-1 public --silent' 8080 'percy exec --config cypress/.percy.json -- cypress run --config-file cypress/cypress.json'",
35+
"test:e2e:local:no-percy": "start-server-and-test 'http-server -c-1 public --silent' 8080 'cypress run --config-file cypress/cypress.json'"
4036
},
4137
"devDependencies": {
4238
"@commitlint/cli": "^17.0.1",
4339
"@commitlint/config-conventional": "^17.0.0",
44-
"@parcel/optimizer-cssnano": "2.0.0-nightly.611",
45-
"@parcel/optimizer-htmlnano": "2.0.0-nightly.611",
46-
"@parcel/packager-css": "2.0.0-nightly.611",
47-
"@parcel/packager-html": "2.0.0-nightly.611",
48-
"@parcel/transformer-css": "2.0.0-nightly.611",
49-
"@parcel/transformer-html": "2.0.0-nightly.611",
50-
"@parcel/transformer-postcss": "2.0.0-nightly.611",
51-
"@parcel/transformer-posthtml": "2.0.0-nightly.611",
5240
"@percy/cli": "^1.2.1",
5341
"@percy/cypress": "^3.1.1",
5442
"archiver": "^3.0.0",
5543
"cypress": "^9.7.0",
5644
"del": "^6.1.1",
5745
"fs-extra": "^7.0.0",
5846
"gulp": "^4.0.2",
47+
"gulp-inject": "^5.0.5",
48+
"gulp-replace": "^1.1.4",
5949
"http-server": "^14.1.0",
6050
"husky": "^7.0.4",
51+
"lerna": "^8.1.2",
6152
"lint-staged": "^12.4.2",
62-
"parcel": "^2.0.0-beta.1",
6353
"postcss": "^8.2.1",
6454
"prettier": "^1.7.4",
6555
"rimraf": "^2.6.2",
66-
"sass": "^1.51.0",
56+
"sass": "^1.77.2",
57+
"server": "^1.0.39",
6758
"start-server-and-test": "^1.14.0"
6859
},
6960
"prettier": {
@@ -90,6 +81,8 @@
9081
"needs": "*"
9182
},
9283
"dependencies": {
93-
"@ibm/telemetry-js": "^1.5.1"
84+
"@ibm/telemetry-js": "^1.5.1",
85+
"glob": "^10.3.12",
86+
"minimist": "^1.2.8"
9487
}
9588
}

0 commit comments

Comments
 (0)