Skip to content

Commit 1cc8939

Browse files
Merge pull request #274 from contentstack/sync/main-change-2.0.4
Sync/main change 2.0.4
2 parents 0023f6c + 4527b1d commit 1cc8939

15 files changed

Lines changed: 835 additions & 49 deletions

File tree

.husky/pre-commit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npx ts-node --esm mustache.ts
4+
npm run build
5+
npx tsx mustache.ts
56
git add .
67
npx lint-staged

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ npm install @contentstack/live-preview-utils
1515
Alternatively, if you want to include the package directly in your website HTML code, use the following command:
1616

1717
```html
18-
<script type='module'>
19-
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@2.0.3';
18+
<script type='module' integrity='sha384-lCmcVfWM6NvgMmsDlPZYYJ9MwFk9oDU3WhsJ3KmUJPWa7iKvIuYl+XzTl+cOCuim' crossorigin="anonymous">
19+
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@2.0.4';
2020
2121
ContentstackLivePreview.init({
2222
stackDetails: {

main.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm install @contentstack/live-preview-utils
1515
Alternatively, if you want to include the package directly in your website HTML code, use the following command:
1616

1717
```html
18-
<script type='module'>
18+
<script type='module' integrity='{{integrity}}' crossorigin="anonymous">
1919
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@{{packageVersion}}';
2020
2121
ContentstackLivePreview.init({

mustache.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
// index.js
22
// import { render } from 'mustache';
33
import * as mustache from 'mustache';
4-
import { readFile, writeFileSync } from 'fs';
4+
import { readFile, readFileSync, writeFileSync } from 'fs';
55
import packageJson from "./package.json" assert { type: "json" };
6+
import ssri from 'ssri';
67
const MUSTACHE_MAIN_DIR = './main.mustache';
8+
const fileContent = readFileSync('./dist/modern/index.js');
9+
const integrity = ssri.fromData(fileContent, { algorithms: ['sha384'] });
710
/**
811
* DATA is the object that contains all
912
* the data to be provided to Mustache
1013
* Notice the "name" and "date" property.
1114
*/
1215
const DATA = {
1316
packageVersion: packageJson.version,
17+
integrity: integrity.toString(),
1418
};
1519
function generateReadMe() {
20+
1621
readFile(MUSTACHE_MAIN_DIR, (err, data) => {
1722
if (err) throw err;
1823
const output = mustache.default.render(data.toString(), DATA);

0 commit comments

Comments
 (0)