@skyscanner/bpk-foundations-ios 6.14.0 → 19.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gulpfile.mjs +125 -0
- package/package.json +4 -4
package/gulpfile.mjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016-2021 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import fs from 'fs';
|
|
20
|
+
import path from 'path';
|
|
21
|
+
import { fileURLToPath } from 'url';
|
|
22
|
+
|
|
23
|
+
import { deleteAsync } from 'del';
|
|
24
|
+
import gulp from 'gulp';
|
|
25
|
+
import jsonLint from 'gulp-jsonlint';
|
|
26
|
+
import gulpTheo from 'gulp-theo';
|
|
27
|
+
import _ from 'lodash';
|
|
28
|
+
import gulpMerge from 'merge2';
|
|
29
|
+
import theo from 'theo';
|
|
30
|
+
|
|
31
|
+
import transformDarkValues from '../../utils/transformDarkValues.mjs';
|
|
32
|
+
|
|
33
|
+
import bpkIosJson from './formatters/bpk.ios.json.mjs';
|
|
34
|
+
import bpkRawJson, { bpkRawJsonIos } from './formatters/bpk.raw.json.mjs';
|
|
35
|
+
|
|
36
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
37
|
+
const __dirname = path.dirname(__filename);
|
|
38
|
+
|
|
39
|
+
const RAW_FORMATS = {
|
|
40
|
+
ios: ['raw.ios.json'],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const PLATFORM_FORMATS = {
|
|
44
|
+
ios: ['ios.json'],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const createTokenSets = (formats) =>
|
|
48
|
+
_.flatten(
|
|
49
|
+
Object.keys(formats).map((platform) =>
|
|
50
|
+
formats[platform].map((format) =>
|
|
51
|
+
typeof format !== 'string'
|
|
52
|
+
? { platform, ...format }
|
|
53
|
+
: { platform, format },
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const rawTokenSets = createTokenSets(RAW_FORMATS);
|
|
59
|
+
const platformTokenSets = createTokenSets(PLATFORM_FORMATS);
|
|
60
|
+
|
|
61
|
+
theo.registerFormat('raw.json', bpkRawJson);
|
|
62
|
+
theo.registerFormat('ios.json', bpkIosJson);
|
|
63
|
+
theo.registerFormat('raw.ios.json', bpkRawJsonIos);
|
|
64
|
+
|
|
65
|
+
theo.registerTransform('ios', ['color/hex8rgba']);
|
|
66
|
+
|
|
67
|
+
gulp.task('clean', (done) => deleteAsync(['tokens'], done));
|
|
68
|
+
|
|
69
|
+
gulp.task('lint', () =>
|
|
70
|
+
gulp
|
|
71
|
+
.src('./src/*.json')
|
|
72
|
+
.pipe(jsonLint())
|
|
73
|
+
.pipe(jsonLint.reporter())
|
|
74
|
+
.pipe(jsonLint.failAfterError()),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const createTokens = (tokenSets, done) => {
|
|
78
|
+
const streams = tokenSets.map(({ format, nest, platform }) => {
|
|
79
|
+
let outputPath = 'tokens';
|
|
80
|
+
|
|
81
|
+
if (nest) {
|
|
82
|
+
outputPath = `${outputPath}/${platform}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return gulp
|
|
86
|
+
.src([`./src/*.json`])
|
|
87
|
+
.pipe(
|
|
88
|
+
gulpTheo({
|
|
89
|
+
transform: { type: platform },
|
|
90
|
+
format: { type: format },
|
|
91
|
+
}),
|
|
92
|
+
)
|
|
93
|
+
.on('error', done)
|
|
94
|
+
.pipe(transformDarkValues())
|
|
95
|
+
.on('error', done)
|
|
96
|
+
.pipe(gulp.dest(path.resolve(__dirname, outputPath)))
|
|
97
|
+
.on('error', done)
|
|
98
|
+
.on(`finish`, () => {
|
|
99
|
+
const oldPath = path.resolve(outputPath, `base.${format}`);
|
|
100
|
+
const newPath = path.resolve(
|
|
101
|
+
outputPath,
|
|
102
|
+
`base.${format}`.split('IOS_').join(''),
|
|
103
|
+
);
|
|
104
|
+
if (oldPath !== newPath) {
|
|
105
|
+
fs.renameSync(oldPath, newPath);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
gulpMerge(streams).on('finish', done);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const createRawTokens = (done) => createTokens(rawTokenSets, done);
|
|
114
|
+
const createPlatformTokens = (done) => createTokens(platformTokenSets, done);
|
|
115
|
+
|
|
116
|
+
gulp.task('tokens:raw', createRawTokens);
|
|
117
|
+
|
|
118
|
+
gulp.task('tokens:platform', createPlatformTokens);
|
|
119
|
+
|
|
120
|
+
gulp.task(
|
|
121
|
+
'tokens',
|
|
122
|
+
gulp.series(gulp.parallel('clean', 'lint'), 'tokens:raw', 'tokens:platform'),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
gulp.task('default', gulp.series('tokens'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/bpk-foundations-ios",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.4.1",
|
|
4
4
|
"description": "Common Backpack design tokens for colors, spacing, font, etc.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"tokens": "gulp"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@skyscanner/bpk-foundations-common": "^
|
|
21
|
-
"color": "^
|
|
20
|
+
"@skyscanner/bpk-foundations-common": "^19.4.1",
|
|
21
|
+
"color": "^5.0.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "fce6283d9a98b0480a45aaab5480729bb66fbc15"
|
|
24
24
|
}
|