Skip to content

Commit

Permalink
- Updated workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Cornu committed Nov 27, 2023
1 parent e43a6a8 commit 3573492
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Run pre-requisites tasks
run: gulp set-version

- name: Build Storybook
run: npx lerna run docs:build --scope=pnp-modern-search-core
Expand Down
48 changes: 0 additions & 48 deletions packages/components/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,16 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const gulp = require("gulp");
const fs = require("fs");
const replace = require("gulp-replace");
const { src, dest } = require("gulp");
const rename = require("gulp-rename");

const versionFile = `
// THIS FILE IS AUTO GENERATED
// ANY CHANGES WILL BE LOST DURING BUILD
export const PACKAGE_VERSION = "[VERSION]";
`;

const envFile = `
// THIS FILE IS AUTO GENERATED
// ANY CHANGES WILL BE LOST DURING BUILD
export const CLIENTID = "[CLIENT_ID]";
export const TENANT_ID = "[TENANT_ID]"
export const DOMAIN_HINT = "[DOMAIN_HINT]";
export const PROFILES_SOURCE_ID = "[PROFILES_SOURCE_ID]"
export const DIST_HOST_URL = "https://[STORAGE_ACCOUNT_NAME].blob.core.windows.net/dist"
`;

const setVersion = () => {
const pkg = require("./package.json");
fs.writeFileSync("./src/utils/version.ts", versionFile.replace("[VERSION]", pkg.version));
};

const setStorybookEnv = () => {

const clientId = process.argv[process.argv.indexOf("--clientId") + 1];
const tenantId = process.argv[process.argv.indexOf("--tenantId") + 1];
const domainHint = process.argv[process.argv.indexOf("--domainHint") + 1];
const profilesSourceId = process.argv[process.argv.indexOf("--profilesSourceId") + 1];
const storageAccount = process.argv[process.argv.indexOf("--storageAccount") + 1];

fs.writeFileSync("./.storybook/addons/env.ts",
envFile.replace("[CLIENT_ID]", clientId)
.replace("[TENANT_ID]", tenantId)
.replace("[DOMAIN_HINT]", domainHint)
.replace("[PROFILES_SOURCE_ID]", profilesSourceId)
.replace("[STORAGE_ACCOUNT_NAME]", storageAccount)
);
};

gulp.task("set-version", async () => setVersion());
gulp.task("set-storybook-env", async () => setStorybookEnv());

gulp.task("update-assets-url", async () => {

const hostUrlArg = process.argv.indexOf("--hosturl");
const hostUrl = process.argv[hostUrlArg+1];

return src("assets/**/*.template.json")
.pipe(replace("{{ASSETS_HOST_URL}}", hostUrl))
.pipe(rename((path) => {
return {
dirname: path.dirname,
basename: path.basename.replace(".template",""),
extname: ".json"
};
}))
.pipe(dest("./assets/"));
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meta, Source } from '@storybook/blocks';
import { PACKAGE_VERSION } from "../../../src/utils/version";
import { DIST_HOST_URL } from "../../../.storybook/addons/env";
import m365logo from "../assets/m365_logo.png";

<Meta title="Introduction / Getting started" />
Expand Down Expand Up @@ -29,7 +28,7 @@ Include the following script in your HTML page:
<Source
dark
language="html"
code={`<script src="${DIST_HOST_URL}/${PACKAGE_VERSION}/bundle.js"></script>`}
code={`<script src="https://www.unpkg.com/pnp-modern-search-core@${PACKAGE_VERSION}/dist/bundle/main.js"></script>`}
/>

> Components are registered automatically on the page when the package is imported.
Expand Down
6 changes: 3 additions & 3 deletions packages/components/webpack.common.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ module.exports = {
},
output: {
chunkFilename: "[name].bundle.js",
filename: "bundle.js",
path: path.resolve(__dirname, "dist/dist"),
filename: "main.js",
path: path.resolve(__dirname, "dist/bundle"),
publicPath: "auto", // Ensure the bundle chunks will be resovled correctly if served from a CDN
clean: true
},
devServer: {
static: {
directory: path.join(__dirname, 'dist/dist'),
directory: path.join(__dirname, 'dist/bundle'),
watch: true,
},
compress: true,
Expand Down

0 comments on commit 3573492

Please sign in to comment.