Skip to content

Commit 13dfe46

Browse files
authored
Merge pull request #89 from IgniteUI/dpetev/update-ci
Update gulp, switch to Actions workflow
2 parents 8e021ab + 59f534f commit 13dfe46

10 files changed

Lines changed: 7353 additions & 1063 deletions

File tree

.github/workflows/build-deploy.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and deploy samples
2+
3+
on:
4+
push:
5+
branches: [ "[0-9]+.[0-9]" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Checkout dist repo
16+
uses: actions/checkout@v3
17+
with:
18+
repository: IgniteUI/help-samples
19+
token: ${{ secrets.GH_PAT }}
20+
path: dist
21+
22+
- name: Setup Node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: lts
26+
27+
- name: Cleanup target version
28+
run: rm -rf dist/${{ github.ref_name }}
29+
30+
- name: Build
31+
run: |
32+
npm install
33+
gulp build-samples --ignite-version ${{ github.ref_name }} --ignite-ui https://cdn-na.infragistics.com/igniteui/latest
34+
35+
- name: Commit and push to dist repo
36+
run: |
37+
cd dist
38+
git config user.email "igniteui@infragistics.com"
39+
git config user.name "igniteui-deploy"
40+
git add --all
41+
if [ -n "$(git status --porcelain)" ]; then git commit -m "Samples for ${{ github.ref_name }}"; fi
42+
git push -fq

.travis.yml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
1414
```
15-
npm run build -- --version 17.1 --ignite-ui http://localhost/ig_ui17.1
15+
npm run build -- --ignite-version 17.1 --ignite-ui http://localhost/ig_ui17.1
1616
```
1717
1818
3. The built samples will be located under the ./dist folder.
Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
var path = require("path"),
2-
cheerio = require("cheerio"),
3-
through = require("through2"),
4-
gutil = require("gulp-util"),
5-
File = gutil.File;
1+
import cheerio from 'cheerio';
2+
import { dirname, join, posix } from "path";
3+
import { obj } from "through2";
4+
import File from 'vinyl';
65
/**
76
* Extracts HTML, JS and optionally CSS into separate files in a fiddle folder
87
* and generates an embed json config file
98
*/
10-
module.exports = function(options) {
9+
export default function(options) {
1110

1211
var replaceSrc = function ($) {
1312
var attr = this.name === "script" ? "src" : "href",
@@ -65,25 +64,25 @@ module.exports = function(options) {
6564

6665
var processStream = function(file, encoding, next){
6766
var contents, stream, $,
68-
basePath = path.dirname(file.path),
67+
basePath = dirname(file.path),
6968
relativePath = basePath.split("HTMLSamples").pop().replace(/\\/g, "/"),
7069
originalPath = "HTMLSamples" + file.originalPath.split("HTMLSamples").pop().replace(/\\/g, "/"),
7170
htmlFile, jsFile, cssFile,
7271
html = [], js = "", css = "",
7372
resultStr = file.lang === "ja" ? options.strings.resultJA : options.strings.resultEN,
7473
embed = {
7574
//use original file path for source link
76-
"srcUrlPattern" : path.posix.join("/${owner}/${repo}-src/blob/", options.version, originalPath),
75+
"srcUrlPattern" : posix.join("/${owner}/${repo}-src/blob/", options.version, originalPath),
7776
"embed": [{
7877
"label": "JS",
79-
"path": path.posix.join(options.version, relativePath, "fiddle/demo.js")
78+
"path": posix.join(options.version, relativePath, "fiddle/demo.js")
8079
},{
8180
"label": "HTML",
82-
"path": path.posix.join(options.version, relativePath, "fiddle/demo.html")
81+
"path": posix.join(options.version, relativePath, "fiddle/demo.html")
8382
}, {
8483
"type": "htmlpage",
8584
"label": resultStr,
86-
"url": options.liveUrl + path.posix.join("/" + options.version, relativePath, "/index.html")
85+
"url": options.liveUrl + posix.join("/" + options.version, relativePath, "/index.html")
8786
}]
8887
};
8988

@@ -119,8 +118,8 @@ module.exports = function(options) {
119118

120119
htmlFile = new File({
121120
base: file.base,
122-
path: path.join(basePath, "fiddle", "demo.html"),
123-
contents: new Buffer(html.join("\r\n"))
121+
path: join(basePath, "fiddle", "demo.html"),
122+
contents: Buffer.from(html.join("\r\n"))
124123
});
125124

126125
// js
@@ -139,8 +138,8 @@ module.exports = function(options) {
139138
}
140139
jsFile = new File({
141140
base: file.base,
142-
path: path.join(basePath, "fiddle", "demo.js"),
143-
contents: new Buffer(js)
141+
path: join(basePath, "fiddle", "demo.js"),
142+
contents: Buffer.from(js)
144143
});
145144

146145
// css
@@ -150,13 +149,13 @@ module.exports = function(options) {
150149
if (css.length) {
151150
cssFile = new File({
152151
base: file.base,
153-
path: path.join(basePath, "fiddle", "demo.css"),
154-
contents: new Buffer(unindentTrim(css))
152+
path: join(basePath, "fiddle", "demo.css"),
153+
contents: Buffer.from(unindentTrim(css))
155154
});
156155
stream.push(cssFile);
157156
embed.embed.splice(2, 0, {
158157
"label": "CSS",
159-
"path": path.posix.join(options.version, relativePath, "fiddle/demo.css")
158+
"path": posix.join(options.version, relativePath, "fiddle/demo.css")
160159
});
161160
}
162161

@@ -167,13 +166,13 @@ module.exports = function(options) {
167166
stream.push(jsFile);
168167
stream.push(new File({
169168
base: file.base,
170-
path: path.join(basePath, ".gh-embed.json"),
171-
contents: new Buffer(JSON.stringify(embed, null, 4))
169+
path: join(basePath, ".gh-embed.json"),
170+
contents: Buffer.from(JSON.stringify(embed, null, 4))
172171
}));
173172

174173
stream.push(file);
175174
next();
176175
};
177176

178-
return through.obj(processStream);
179-
};
177+
return obj(processStream);
178+
};
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
1-
var path = require("path"),
2-
through = require("through2"),
3-
gutil = require("gulp-util"),
4-
File = gutil.File;
1+
import { createRequire } from "module";
2+
import { basename, dirname, extname, join, sep } from "path";
3+
import { obj } from "through2";
4+
import File from 'vinyl';
5+
6+
const require = createRequire(import.meta.url);
57

68
/**
79
* Localize contents of file (resources, localization strings) and push both versions back to stream
810
*/
9-
module.exports = function(options) {
11+
export default function(_options) {
1012

1113
var processStream = function(file, encoding, next){
1214
var contentsEN, contentsJA, jaFile, token,
13-
basePath = path.dirname(file.path),
14-
fileName = path.basename(file.path, path.extname(file.path)),
15+
basePath = dirname(file.path),
16+
fileName = basename(file.path, extname(file.path)),
1517
enStrings, jaStrings,
1618
stream = this;
1719
contentsEN = contentsJA = file.contents.toString(encoding);
1820

19-
enStrings = require(path.join(basePath, "strings-en.json"));
20-
jaStrings = require(path.join(basePath, "strings-ja.json"));
21+
enStrings = require(join(basePath, "strings-en.json"));
22+
jaStrings = require(join(basePath, "strings-ja.json"));
2123
// combine with shared strings
22-
Object.assign(enStrings, require(path.join(basePath, "../strings-en.json")));
23-
Object.assign(jaStrings, require(path.join(basePath, "../strings-ja.json")));
24+
Object.assign(enStrings, require(join(basePath, "../strings-en.json")));
25+
Object.assign(jaStrings, require(join(basePath, "../strings-ja.json")));
2426

25-
for (key in enStrings) {
27+
for (const key in enStrings) {
2628
token = new RegExp("\\$\\$\\(" + key + "\\)", "g");
2729
contentsEN = contentsEN.replace(token, enStrings[key]);
2830
}
2931

30-
for (key in jaStrings) {
32+
for (const key in jaStrings) {
3133
token = new RegExp("\\$\\$\\(" + key + "\\)", "g");
3234
contentsJA = contentsJA.replace(token, jaStrings[key]);
3335
}
3436

3537
// save original path, because hystory stack won't be available for the newly created JA file:
3638
file.originalPath = file.history[0];
3739
// change out path, HTMLSamples must remain in path to keep relative correct for dest
38-
file.path = path.join(basePath.replace("HTMLSamples", "HTMLSamples" + path.sep + "EN"), fileName, "index.html");
39-
file.contents = new Buffer(contentsEN, encoding);
40+
file.path = join(basePath.replace("HTMLSamples", "HTMLSamples" + sep + "EN"), fileName, "index.html");
41+
file.contents = Buffer.from(contentsEN, encoding);
4042
file.lang = "en";
4143

4244
// replace JA
4345
jaFile = new File({
4446
base: file.base,
45-
path: path.join(basePath.replace("HTMLSamples", "HTMLSamples" + path.sep + "JA"), fileName, "index.html"),
46-
contents: new Buffer(contentsJA)
47+
path: join(basePath.replace("HTMLSamples", "HTMLSamples" + sep + "JA"), fileName, "index.html"),
48+
contents: Buffer.from(contentsJA)
4749
});
4850
jaFile.lang = "ja";
4951
jaFile.originalPath = file.originalPath;
@@ -53,5 +55,5 @@ module.exports = function(options) {
5355
next();
5456
};
5557

56-
return through.obj(processStream);
57-
};
58+
return obj(processStream);
59+
};
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
var path = require("path"),
2-
fs = require("fs"),
3-
cheerio = require("cheerio"),
4-
through = require("through2"),
5-
gutil = require("gulp-util"),
6-
File = gutil.File;
1+
import cheerio from 'cheerio';
2+
import { existsSync } from "fs";
3+
import { obj } from "through2";
74

85
/**
96
* Replace resource strings (src, href) and igLoader sources. Adds Japanese locale script for JA files.
107
*/
11-
module.exports = function (options) {
8+
export default function (options) {
129

1310
/**
1411
* Replaces %%resource%% links based on configuration. Swaps to Japanese data-file if available for localized files.
@@ -26,7 +23,7 @@ module.exports = function (options) {
2623
if (lang === "ja" && src.indexOf("../data-files") !== -1) {
2724
// check if respective japanese files is available:
2825
dataFile = src.split("../data-files/").pop();
29-
if (fs.existsSync("./data-files-ja/" + dataFile)) {
26+
if (existsSync("./data-files-ja/" + dataFile)) {
3027
src = src.replace("/data-files/", "/data-files-ja/");
3128
}
3229
}
@@ -85,11 +82,11 @@ module.exports = function (options) {
8582
});
8683

8784

88-
file.contents = new Buffer($.html(), encoding);
85+
file.contents = Buffer.from($.html(), encoding);
8986

9087
stream.push(file);
9188
next();
9289
};
9390

94-
return through.obj(processStream);
95-
};
91+
return obj(processStream);
92+
};

gulpfile.js

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

0 commit comments

Comments
 (0)