Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(embed): publish the code embed assets to npm #58

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat(embed): publish the code embed assets to npm
  • Loading branch information
tericcabrel committed Nov 4, 2023
commit dd71e4737cd09a78d052b44461f10a9574aaf857
11 changes: 5 additions & 6 deletions .github/workflows/publish-embed.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Snipcode embed assets to npmjs
name: Publish Snipcode Embed assets to NPM
on:
push:
branches: [main]
Expand All @@ -11,7 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
Expand All @@ -21,11 +20,11 @@ jobs:
uses: bahmutov/npm-install@v1

- name: Publish to NPM
working-directory: packages/embed
run: |
yarn build:cdn
cp package.publish.json build/package.json
cp README.publish.md build/README.md
cd build
yarn publish
working-directory: packages/embed
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
yarn publish:lib
1 change: 1 addition & 0 deletions apps/core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typings/
../../packages/domain/.env.test
.env*.local
.env.docker
.env.dev

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
2 changes: 1 addition & 1 deletion apps/functions/code-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/aws-lambda": "^8.10.102",
"@types/node": "^17.0.45",
"esbuild": "^0.15.5",
"serverless": "^3.22.0",
"serverless": "^3.36.0",
"serverless-certificate-creator": "^1.6.0",
"serverless-domain-manager": "^6.1.0",
"serverless-esbuild": "^1.32.8",
Expand Down
9 changes: 6 additions & 3 deletions packages/embed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ yarn iframe:preview
Navigate to the URL [https://localhost:7503](https://localhost:7503) to see the result.

## Publish the assets on NPM
This part is handled inside the CI/CD, so it will not be useful to do it locally:
This part is handled inside the CI/CD, so it will not be useful to do it locally.
You will need the NPM access token; ask it to [@tericcabrel](https://github.com/tericcabrel))

```shell
# Generate the assets optimized for production
yarn build:cdn
cp package.publish.json build/package.json
cp README.publish.md build/README.md
cd build
# Authenticate to NPM
npm adduser
# Store the NPM access token
npm config set //registry.npmjs.org/:_authToken <npm_token>
# Publish the package on NPM
npm publish --access=public
```
Expand Down
10 changes: 10 additions & 0 deletions packages/embed/README.publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Snipcode Embed

This package contains the script and style assets for code snippet rendering in an embed.

To use it, include the CSS and JavaScript link to JSDelivr file.

```html
<link rel="stylesheet" type="text/css" href="https://jsdelivr.net/npm/@snipcode/[email protected]/style.min.css" />
<script type="text/javascript" src="https://jsdelivr.net/npm/@snipcode/[email protected]/script.min.css"></script>
```
4 changes: 2 additions & 2 deletions packages/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@snipcode/embed",
"version": "1.0.0",
"main": "dist/index.js",
"description": "Build the script and style assets for code snippet rendering in an embed.",
"repository": " https://github.com/tericcabrel/snipcode.git",
"author": "Eric Cabrel TIOGO <[email protected]>",
"license": "MIT",
Expand All @@ -14,7 +14,7 @@
"dev": "nodemon --watch \"*.ts\" --exec \"ts-node\" ./src/server/index.ts",
"lint": "eslint src",
"iframe:preview": "serve ./src/server/static -l 7503",
"push": "cp package.publish.json build/package.json && cd build && npm publish --access=public",
"publish:lib": "cp package.publish.json build/package.json && cp README.publish.md build/README.md && cd build && npm publish --access=public",
"test": "jest"
},
"devDependencies": {
Expand Down
18 changes: 13 additions & 5 deletions packages/embed/package.publish.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "snipcode-embed",
"version": "1.1.0",
"repository": "https://github.com/tericcabrel/snipcode.git",
"author": "Eric Cabrel TIOGO <[email protected]>",
"license": "MIT"
"name": "@snipcode/embed",
"version": "1.1.2",
"repository": {
"type": "git",
"url": "https://github.com/tericcabrel/snipcode.git"
},
"homepage": "https://github.com/tericcabrel/snipcode/blob/main/packages/embed/README.md",
"author": "Eric Cabrel TIOGO",
"license": "MIT",
"keywords": ["code snippet", "snipcode", "snippets", "embed"],
"contributors": [
"Eric Cabrel TIOGO (https://github.com/tericcabrel)"
]
}