Skip to content

Commit fd32058

Browse files
authored
Add github pages templates (#1324)
* add github pages templates * refactor updateWorkflows function and update tests * feat(cli): add basename to main tsx for react github pages template * feat(cli): fix whitespaces * feat(cli): fix whitespaces * chore: release 14.2.0-beta.0 * chore: release 14.2.1-beta.1 * feat(cli): add logic for build path in github pages yml * chore: release 14.2.0-beta.2 * feat(cli): fix replacements in angular templates * feat(cli): fix replacements in github io and node yml for angular templates * chore: release 14.2.0-beta.3
1 parent 4d89fad commit fd32058

File tree

21 files changed

+364
-34
lines changed

21 files changed

+364
-34
lines changed

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "igniteui-cli",
3-
"version": "14.1.0",
3+
"version": "14.2.0-beta.3",
44
"description": "CLI tool for creating Ignite UI projects",
55
"keywords": [
66
"CLI",
@@ -78,8 +78,8 @@
7878
"all": true
7979
},
8080
"dependencies": {
81-
"@igniteui/angular-templates": "~18.1.1410",
82-
"@igniteui/cli-core": "~14.1.0",
81+
"@igniteui/angular-templates": "~18.2.1420-beta.3",
82+
"@igniteui/cli-core": "~14.2.0-beta.3",
8383
"@inquirer/prompts": "^5.4.0",
8484
"@types/yargs": "^17.0.33",
8585
"chalk": "^5.3.0",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ <%=yamlDefaultBranch%> ]
6+
pull_request:
7+
branches: [ <%=yamlDefaultBranch%> ]
8+
9+
jobs:
10+
build-and-deploy:
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
pages: write
16+
id-token: write
17+
18+
strategy:
19+
matrix:
20+
node-version: [18.x, 20.x]
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
# cache: 'npm' # enable after committing lock file from first install
29+
- run: npm i # replace with 'npm ci' after committing lock file from first install
30+
- name: Set environment variable for basename
31+
run: echo "VITE_BASENAME=/${{ github.event.repository.name }}" >> $GITHUB_ENV
32+
- run: npm run build -- --base=/${{ github.event.repository.name }}/
33+
- name: Update Resource Paths
34+
run: find ./dist/assets -name "*.js" -exec sed -i 's|src/assets|${{ github.event.repository.name }}/assets|g' {} +
35+
- name: Copy Resources to dist
36+
run: mkdir -p ./dist/assets && cp -R ./src/assets/* ./dist/assets/
37+
- name: Upload build artifact to GitHub Pages
38+
uses: actions/upload-pages-artifact@v1
39+
with:
40+
path: ./dist
41+
- name: Deploy to GitHub Pages
42+
uses: actions/deploy-pages@v1

packages/cli/templates/react/igr-ts/projects/_base/files/src/main.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import App from './app/app';
55
import { routes } from "./app/app-routes";
66
import 'react-app-polyfill/ie11';
77

8+
const basename = import.meta.env.VITE_BASENAME || '/';
9+
810
/** Required in IE11 for Charts */
911
Number.isNaN = Number.isNaN || function(value) {
1012
return value !== value;
@@ -15,7 +17,10 @@ const router = createBrowserRouter([
1517
element: <App />,
1618
children: [...routes]
1719
}
18-
]);
20+
],
21+
{
22+
basename: basename
23+
});
1924

2025
ReactDOM.createRoot(document.getElementById('root')!).render(
2126
<React.StrictMode>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ <%=yamlDefaultBranch%> ]
6+
pull_request:
7+
branches: [ <%=yamlDefaultBranch%> ]
8+
9+
jobs:
10+
build-and-deploy:
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
pages: write
16+
id-token: write
17+
18+
strategy:
19+
matrix:
20+
node-version: [18.x, 20.x]
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
# cache: 'npm' # enable after committing lock file from first install
29+
- run: npm i # replace with 'npm ci' after committing lock file from first install
30+
- run: npm run build
31+
- name: Update base href in index.html
32+
run: sed -i 's|<base href="[^"]*"|<base href="/${{ github.event.repository.name }}/">|' ./dist/index.html
33+
- name: Update Resource Paths
34+
run: find ./dist -maxdepth 1 -type f ! -name 'sw*.js' ! -name 'workbox*.js' -name '*.js' -exec sed -i -e "s|/src/assets|/${{ github.event.repository.name }}/src/assets|g" -e "s|url('/src/assets|url('/${{ github.event.repository.name }}/src/assets|g" {} +
35+
- name: Copy ig-theme.css to dist
36+
run: cp ./ig-theme.css ./dist/
37+
- name: Update href Paths for ig-theme.css
38+
run: find ./dist -type f -exec sed -i "s|href=\"../../ig-theme.css\"|href=\"../../${{ github.event.repository.name }}/ig-theme.css\"|g" {} +
39+
- name: Upload build artifact to GitHub Pages
40+
uses: actions/upload-pages-artifact@v1
41+
with:
42+
path: ./dist
43+
- name: Deploy to GitHub Pages
44+
uses: actions/deploy-pages@v1

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@igniteui/cli-core",
3-
"version": "14.1.0",
3+
"version": "14.2.0-beta.3",
44
"description": "Base types and functionality for Ignite UI CLI",
55
"repository": {
66
"type": "git",

packages/core/update/Update.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,21 @@ function updatePackageJsonFiles(
198198
function updateWorkflows(
199199
fs: IFileSystem
200200
): void {
201-
const workflowPath = ".github/workflows/node.js.yml";
202-
let workflow = fs.readFile(workflowPath);
203-
if (workflow) {
204-
const oldNmpInstall = "- run: npm i # replace with \'npm ci\' after committing lock file from first install";
205-
const newNpmInstall =
201+
const workflowFiles = ["node.js.yml", "github.io.yml"];
202+
const oldNpmInstall = "- run: npm i # replace with 'npm ci' after committing lock file from first install";
203+
const newNpmInstall =
206204
`- run: echo "@infragistics:registry=https://packages.infragistics.com/npm/js-licensed/" >> ~/.npmrc
207205
- run: echo "//packages.infragistics.com/npm/js-licensed/:_auth=\${{ secrets.NPM_AUTH_TOKEN }}" >> ~/.npmrc
208206
- run: echo "//packages.infragistics.com/npm/js-licensed/:always-auth=true" >> ~/.npmrc
209-
- run: npm i # replace with \'npm ci\' after committing lock file from first install`;
210-
workflow = workflow.replace(oldNmpInstall, newNpmInstall);
211-
fs.writeFile(workflowPath, workflow);
207+
- run: npm i # replace with 'npm ci' after committing lock file from first install`;
208+
209+
for (const fileName of workflowFiles) {
210+
const workflowPath = `.github/workflows/${fileName}`;
211+
let workflow = fs.readFile(workflowPath);
212+
if (workflow) {
213+
workflow = workflow.replace(oldNpmInstall, newNpmInstall);
214+
fs.writeFile(workflowPath, workflow);
215+
}
212216
}
213217
}
214218

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ <%=yamlDefaultBranch%> ]
6+
pull_request:
7+
branches: [ <%=yamlDefaultBranch%> ]
8+
9+
jobs:
10+
build-and-deploy:
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
pages: write
16+
id-token: write
17+
18+
strategy:
19+
matrix:
20+
node-version: [18.x, 20.x]
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
# cache: 'npm' # enable after committing lock file from first install
29+
- run: npm i # replace with 'npm ci' after committing lock file from first install
30+
- name: Set project name
31+
run: echo "PROJECT_NAME=$(jq -r '.name' package.json)" >> $GITHUB_ENV
32+
- name: Determine if project is standalone and set build path
33+
run: |
34+
if jq -e ".projects[\"${{ env.PROJECT_NAME }}\"].schematics[\"@schematics/angular:application\"].standalone == false" angular.json > /dev/null; then
35+
echo "BUILD_PATH=./dist/${{ env.PROJECT_NAME }}" >> $GITHUB_ENV
36+
else
37+
echo "BUILD_PATH=./dist/${{ env.PROJECT_NAME }}/browser" >> $GITHUB_ENV
38+
fi
39+
- name: Build project with dynamic base-href
40+
run: npm run build -- --base-href "/${{ github.event.repository.name }}/"
41+
- name: Update Resource Paths
42+
run: find ${{ env.BUILD_PATH }} -type f -name '*main*.js' -exec sed -i -e "s|/assets|/${{ github.event.repository.name }}/assets|g" -e "s|url('/assets|url('/${{ github.event.repository.name }}/assets|g" {} +
43+
- name: Upload build artifact to GitHub Pages
44+
uses: actions/upload-pages-artifact@v1
45+
with:
46+
path: ${{ env.BUILD_PATH }}
47+
- name: Deploy to GitHub Pages
48+
uses: actions/deploy-pages@v1

packages/igx-templates/igx-ts-legacy/projects/_base/files/__dot__github/workflows/node.js.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
uses: actions/setup-node@v2
2929
with:
3030
node-version: ${{ matrix.node-version }}
31-
cache: 'npm'
32-
- run: npm ci
31+
# cache: 'npm' # enable after committing lock file from first install
32+
- run: npm i # replace with 'npm ci' after committing lock file from first install
3333
- run: npm run lint
3434
- run: npm run build
3535
- run: npm run test -- --watch=false --browsers ChromeHeadless

packages/igx-templates/igx-ts-legacy/projects/_base/files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@angular/platform-browser-dynamic": "~18.2.0",
2121
"@angular/router": "~18.2.0",
2222
"hammerjs": "^2.0.8",
23-
"igniteui-angular": "~18.2.0-beta.2",
23+
"igniteui-angular": "~18.2.0-rc.0",
2424
"minireset.css": "~0.0.7",
2525
"rxjs": "~7.8.0",
2626
"tslib": "~2.3.0",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-deploy:
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
pages: write
16+
id-token: write
17+
18+
strategy:
19+
matrix:
20+
node-version: [18.x, 20.x]
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
# cache: 'npm' # enable after committing lock file from first install
29+
- run: npm i # replace with 'npm ci' after committing lock file from first install
30+
- name: Set project name
31+
run: echo "PROJECT_NAME=$(jq -r '.name' package.json)" >> $GITHUB_ENV
32+
- name: Determine if project is standalone and set build path
33+
run: |
34+
if jq -e ".projects[\"${{ env.PROJECT_NAME }}\"].schematics[\"@schematics/angular:application\"].standalone == false" angular.json > /dev/null; then
35+
echo "BUILD_PATH=./dist/${{ env.PROJECT_NAME }}" >> $GITHUB_ENV
36+
else
37+
echo "BUILD_PATH=./dist/${{ env.PROJECT_NAME }}/browser" >> $GITHUB_ENV
38+
fi
39+
- name: Build project with dynamic base-href
40+
run: npm run build -- --base-href "/${{ github.event.repository.name }}/"
41+
- name: Update Resource Paths
42+
run: find ${{ env.BUILD_PATH }} -type f -name '*main*.js' -exec sed -i -e "s|/assets|/${{ github.event.repository.name }}/assets|g" -e "s|url('/assets|url('/${{ github.event.repository.name }}/assets|g" {} +
43+
- name: Upload build artifact to GitHub Pages
44+
uses: actions/upload-pages-artifact@v1
45+
with:
46+
path: ${{ env.BUILD_PATH }}
47+
- name: Deploy to GitHub Pages
48+
uses: actions/deploy-pages@v1

0 commit comments

Comments
 (0)