Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and deploy samples

on:
push:
branches: [ "[0-9]+.[0-9]" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Checkout dist repo
uses: actions/checkout@v3
with:
repository: IgniteUI/help-samples
token: ${{ secrets.GH_PAT }}
path: dist

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: lts

- name: Cleanup target version
run: rm -rf dist/${{ github.ref_name }}

- name: Build
run: |
npm install
gulp build-samples --ignite-version ${{ github.ref_name }} --ignite-ui https://cdn-na.infragistics.com/igniteui/latest

- name: Commit and push to dist repo
run: |
cd dist
git config user.email "igniteui@infragistics.com"
git config user.name "igniteui-deploy"
git add --all
if [ -n "$(git status --porcelain)" ]; then git commit -m "Samples for ${{ github.ref_name }}"; fi
git push -fq
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


```
npm run build -- --version 17.1 --ignite-ui http://localhost/ig_ui17.1
npm run build -- --ignite-version 17.1 --ignite-ui http://localhost/ig_ui17.1
```

3. The built samples will be located under the ./dist folder.
43 changes: 21 additions & 22 deletions build/createFiddleFiles.js → build/createFiddleFiles.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var path = require("path"),
cheerio = require("cheerio"),
through = require("through2"),
gutil = require("gulp-util"),
File = gutil.File;
import cheerio from 'cheerio';
import { dirname, join, posix } from "path";
import { obj } from "through2";
import File from 'vinyl';
/**
* Extracts HTML, JS and optionally CSS into separate files in a fiddle folder
* and generates an embed json config file
*/
module.exports = function(options) {
export default function(options) {

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

var processStream = function(file, encoding, next){
var contents, stream, $,
basePath = path.dirname(file.path),
basePath = dirname(file.path),
relativePath = basePath.split("HTMLSamples").pop().replace(/\\/g, "/"),
originalPath = "HTMLSamples" + file.originalPath.split("HTMLSamples").pop().replace(/\\/g, "/"),
htmlFile, jsFile, cssFile,
html = [], js = "", css = "",
resultStr = file.lang === "ja" ? options.strings.resultJA : options.strings.resultEN,
embed = {
//use original file path for source link
"srcUrlPattern" : path.posix.join("/${owner}/${repo}-src/blob/", options.version, originalPath),
"srcUrlPattern" : posix.join("/${owner}/${repo}-src/blob/", options.version, originalPath),
"embed": [{
"label": "JS",
"path": path.posix.join(options.version, relativePath, "fiddle/demo.js")
"path": posix.join(options.version, relativePath, "fiddle/demo.js")
},{
"label": "HTML",
"path": path.posix.join(options.version, relativePath, "fiddle/demo.html")
"path": posix.join(options.version, relativePath, "fiddle/demo.html")
}, {
"type": "htmlpage",
"label": resultStr,
"url": options.liveUrl + path.posix.join("/" + options.version, relativePath, "/index.html")
"url": options.liveUrl + posix.join("/" + options.version, relativePath, "/index.html")
}]
};

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

htmlFile = new File({
base: file.base,
path: path.join(basePath, "fiddle", "demo.html"),
contents: new Buffer(html.join("\r\n"))
path: join(basePath, "fiddle", "demo.html"),
contents: Buffer.from(html.join("\r\n"))
});

// js
Expand All @@ -139,8 +138,8 @@ module.exports = function(options) {
}
jsFile = new File({
base: file.base,
path: path.join(basePath, "fiddle", "demo.js"),
contents: new Buffer(js)
path: join(basePath, "fiddle", "demo.js"),
contents: Buffer.from(js)
});

// css
Expand All @@ -150,13 +149,13 @@ module.exports = function(options) {
if (css.length) {
cssFile = new File({
base: file.base,
path: path.join(basePath, "fiddle", "demo.css"),
contents: new Buffer(unindentTrim(css))
path: join(basePath, "fiddle", "demo.css"),
contents: Buffer.from(unindentTrim(css))
});
stream.push(cssFile);
embed.embed.splice(2, 0, {
"label": "CSS",
"path": path.posix.join(options.version, relativePath, "fiddle/demo.css")
"path": posix.join(options.version, relativePath, "fiddle/demo.css")
});
}

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

stream.push(file);
next();
};

return through.obj(processStream);
};
return obj(processStream);
};
40 changes: 21 additions & 19 deletions build/localizeFiles.js → build/localizeFiles.mjs
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
var path = require("path"),
through = require("through2"),
gutil = require("gulp-util"),
File = gutil.File;
import { createRequire } from "module";
import { basename, dirname, extname, join, sep } from "path";
import { obj } from "through2";
import File from 'vinyl';

const require = createRequire(import.meta.url);

/**
* Localize contents of file (resources, localization strings) and push both versions back to stream
*/
module.exports = function(options) {
export default function(_options) {

var processStream = function(file, encoding, next){
var contentsEN, contentsJA, jaFile, token,
basePath = path.dirname(file.path),
fileName = path.basename(file.path, path.extname(file.path)),
basePath = dirname(file.path),
fileName = basename(file.path, extname(file.path)),
enStrings, jaStrings,
stream = this;
contentsEN = contentsJA = file.contents.toString(encoding);

enStrings = require(path.join(basePath, "strings-en.json"));
jaStrings = require(path.join(basePath, "strings-ja.json"));
enStrings = require(join(basePath, "strings-en.json"));
jaStrings = require(join(basePath, "strings-ja.json"));
// combine with shared strings
Object.assign(enStrings, require(path.join(basePath, "../strings-en.json")));
Object.assign(jaStrings, require(path.join(basePath, "../strings-ja.json")));
Object.assign(enStrings, require(join(basePath, "../strings-en.json")));
Object.assign(jaStrings, require(join(basePath, "../strings-ja.json")));

for (key in enStrings) {
for (const key in enStrings) {
token = new RegExp("\\$\\$\\(" + key + "\\)", "g");
contentsEN = contentsEN.replace(token, enStrings[key]);
}

for (key in jaStrings) {
for (const key in jaStrings) {
token = new RegExp("\\$\\$\\(" + key + "\\)", "g");
contentsJA = contentsJA.replace(token, jaStrings[key]);
}

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

// replace JA
jaFile = new File({
base: file.base,
path: path.join(basePath.replace("HTMLSamples", "HTMLSamples" + path.sep + "JA"), fileName, "index.html"),
contents: new Buffer(contentsJA)
path: join(basePath.replace("HTMLSamples", "HTMLSamples" + sep + "JA"), fileName, "index.html"),
contents: Buffer.from(contentsJA)
});
jaFile.lang = "ja";
jaFile.originalPath = file.originalPath;
Expand All @@ -53,5 +55,5 @@ module.exports = function(options) {
next();
};

return through.obj(processStream);
};
return obj(processStream);
};
19 changes: 8 additions & 11 deletions build/updateResources.js → build/updateResources.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
var path = require("path"),
fs = require("fs"),
cheerio = require("cheerio"),
through = require("through2"),
gutil = require("gulp-util"),
File = gutil.File;
import cheerio from 'cheerio';
import { existsSync } from "fs";
import { obj } from "through2";

/**
* Replace resource strings (src, href) and igLoader sources. Adds Japanese locale script for JA files.
*/
module.exports = function (options) {
export default function (options) {

/**
* Replaces %%resource%% links based on configuration. Swaps to Japanese data-file if available for localized files.
Expand All @@ -26,7 +23,7 @@ module.exports = function (options) {
if (lang === "ja" && src.indexOf("../data-files") !== -1) {
// check if respective japanese files is available:
dataFile = src.split("../data-files/").pop();
if (fs.existsSync("./data-files-ja/" + dataFile)) {
if (existsSync("./data-files-ja/" + dataFile)) {
src = src.replace("/data-files/", "/data-files-ja/");
}
}
Expand Down Expand Up @@ -85,11 +82,11 @@ module.exports = function (options) {
});


file.contents = new Buffer($.html(), encoding);
file.contents = Buffer.from($.html(), encoding);

stream.push(file);
next();
};

return through.obj(processStream);
};
return obj(processStream);
};
52 changes: 0 additions & 52 deletions gulpfile.js

This file was deleted.

Loading