From dd71e4737cd09a78d052b44461f10a9574aaf857 Mon Sep 17 00:00:00 2001 From: Eric Cabrel TIOGO Date: Sat, 4 Nov 2023 23:26:30 +0100 Subject: [PATCH 1/2] feat(embed): publish the code embed assets to npm --- .github/workflows/publish-embed.yml | 11 +++++------ apps/core/.gitignore | 1 + apps/functions/code-embed/package.json | 2 +- packages/embed/README.md | 9 ++++++--- packages/embed/README.publish.md | 10 ++++++++++ packages/embed/package.json | 4 ++-- packages/embed/package.publish.json | 18 +++++++++++++----- 7 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 packages/embed/README.publish.md diff --git a/.github/workflows/publish-embed.yml b/.github/workflows/publish-embed.yml index 91454059..0198d0a5 100644 --- a/.github/workflows/publish-embed.yml +++ b/.github/workflows/publish-embed.yml @@ -1,4 +1,4 @@ -name: Publish Snipcode embed assets to npmjs +name: Publish Snipcode Embed assets to NPM on: push: branches: [main] @@ -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' @@ -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 diff --git a/apps/core/.gitignore b/apps/core/.gitignore index 7f738fdd..2aa5c054 100644 --- a/apps/core/.gitignore +++ b/apps/core/.gitignore @@ -77,6 +77,7 @@ typings/ ../../packages/domain/.env.test .env*.local .env.docker +.env.dev # parcel-bundler cache (https://parceljs.org/) .cache diff --git a/apps/functions/code-embed/package.json b/apps/functions/code-embed/package.json index 7e9aeaad..eb5547fc 100644 --- a/apps/functions/code-embed/package.json +++ b/apps/functions/code-embed/package.json @@ -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", diff --git a/packages/embed/README.md b/packages/embed/README.md index 1a073c50..4e42ea45 100644 --- a/packages/embed/README.md +++ b/packages/embed/README.md @@ -69,14 +69,17 @@ yarn iframe:preview Navigate to the URL [http://localhost:7503](http://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 # Publish the package on NPM npm publish --access=public ``` diff --git a/packages/embed/README.publish.md b/packages/embed/README.publish.md new file mode 100644 index 00000000..a1471078 --- /dev/null +++ b/packages/embed/README.publish.md @@ -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 + + +``` diff --git a/packages/embed/package.json b/packages/embed/package.json index cc6e1397..9c43d3c7 100644 --- a/packages/embed/package.json +++ b/packages/embed/package.json @@ -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 ", "license": "MIT", @@ -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": { diff --git a/packages/embed/package.publish.json b/packages/embed/package.publish.json index f743f948..0b661466 100644 --- a/packages/embed/package.publish.json +++ b/packages/embed/package.publish.json @@ -1,7 +1,15 @@ { - "name": "snipcode-embed", - "version": "1.1.0", - "repository": "https://github.com/tericcabrel/snipcode.git", - "author": "Eric Cabrel TIOGO ", - "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)" + ] } From a2fe2ea00f78da2ce38b0c253934e9eb5ffb5f7d Mon Sep 17 00:00:00 2001 From: Eric Cabrel TIOGO Date: Sat, 4 Nov 2023 23:30:45 +0100 Subject: [PATCH 2/2] fix: rename files --- .github/workflows/build.yml | 2 +- .github/workflows/deploy-code-embed.yml | 2 +- .github/workflows/deploy-core.yml | 2 +- .github/workflows/publish-embed.yml | 2 +- .github/workflows/sentry-release.yml | 2 +- apps/functions/code-embed/package.json | 2 +- packages/embed/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dce50302..b9c2470e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Snipcode Build +name: Build Project on: pull_request: branches: [ main ] diff --git a/.github/workflows/deploy-code-embed.yml b/.github/workflows/deploy-code-embed.yml index 3e65bb8e..fe3c9eea 100644 --- a/.github/workflows/deploy-code-embed.yml +++ b/.github/workflows/deploy-code-embed.yml @@ -1,4 +1,4 @@ -name: Snipcode Deploy Code Embed +name: Deploy Code Embed on: push: branches: diff --git a/.github/workflows/deploy-core.yml b/.github/workflows/deploy-core.yml index 016e0f28..06dc9335 100644 --- a/.github/workflows/deploy-core.yml +++ b/.github/workflows/deploy-core.yml @@ -1,4 +1,4 @@ -name: Snipcode Deploy Core +name: Deploy Core Backend on: push: branches: diff --git a/.github/workflows/publish-embed.yml b/.github/workflows/publish-embed.yml index 0198d0a5..f25984e3 100644 --- a/.github/workflows/publish-embed.yml +++ b/.github/workflows/publish-embed.yml @@ -1,4 +1,4 @@ -name: Publish Snipcode Embed assets to NPM +name: Publish Embed assets to NPM on: push: branches: [main] diff --git a/.github/workflows/sentry-release.yml b/.github/workflows/sentry-release.yml index 5ff5fa54..50ab686a 100644 --- a/.github/workflows/sentry-release.yml +++ b/.github/workflows/sentry-release.yml @@ -1,4 +1,4 @@ -name: Sentry release source maps +name: Release Source maps to Sentry on: push: branches: diff --git a/apps/functions/code-embed/package.json b/apps/functions/code-embed/package.json index eb5547fc..7e9aeaad 100644 --- a/apps/functions/code-embed/package.json +++ b/apps/functions/code-embed/package.json @@ -27,7 +27,7 @@ "@types/aws-lambda": "^8.10.102", "@types/node": "^17.0.45", "esbuild": "^0.15.5", - "serverless": "^3.36.0", + "serverless": "^3.22.0", "serverless-certificate-creator": "^1.6.0", "serverless-domain-manager": "^6.1.0", "serverless-esbuild": "^1.32.8", diff --git a/packages/embed/package.json b/packages/embed/package.json index 9c43d3c7..0ac9133c 100644 --- a/packages/embed/package.json +++ b/packages/embed/package.json @@ -1,6 +1,6 @@ { "name": "@snipcode/embed", - "version": "1.0.0", + "version": "1.1.2", "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 ",