From 6f8053bbacdc43b501e78aa27797bbeffbf2a24b Mon Sep 17 00:00:00 2001 From: Bryan Jonker <65776851+bryanjonker-illinois@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:47:17 -0500 Subject: [PATCH 1/4] Create publish_npm.yml --- .github/workflows/publish_npm.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/publish_npm.yml diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml new file mode 100644 index 0000000..2c4707e --- /dev/null +++ b/.github/workflows/publish_npm.yml @@ -0,0 +1,21 @@ +name: publish_npm +on: + workflow_dispatch: + push: + tags: [ '**' ] + pull_request: + tags: [ '**' ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22.x' + registry-url: 'https://registry.npmjs.org' + - name: Install to npm + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.TOOLKIT_NPM_SECRET}} From 9a1f9091906ee932e27aa29b39f26fc3b861efce Mon Sep 17 00:00:00 2001 From: Bryan Jonker <65776851+bryanjonker-illinois@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:32:27 -0500 Subject: [PATCH 2/4] Update publish_npm.yml Remove pull_request --- .github/workflows/publish_npm.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml index 2c4707e..99e0d43 100644 --- a/.github/workflows/publish_npm.yml +++ b/.github/workflows/publish_npm.yml @@ -3,8 +3,6 @@ on: workflow_dispatch: push: tags: [ '**' ] - pull_request: - tags: [ '**' ] jobs: build: runs-on: ubuntu-latest From de0f9917f1a600c5f39793ab607a323a2ecb5458 Mon Sep 17 00:00:00 2001 From: Bryan Jonker <65776851+bryanjonker-illinois@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:58:47 -0500 Subject: [PATCH 3/4] Update publish_npm.yml Adding build script to create /dist files --- .github/workflows/publish_npm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml index 99e0d43..529d9af 100644 --- a/.github/workflows/publish_npm.yml +++ b/.github/workflows/publish_npm.yml @@ -13,6 +13,9 @@ jobs: with: node-version: '22.x' registry-url: 'https://registry.npmjs.org' + - run: npm install + - run: npm rebuild + - run: npm run-script build - name: Install to npm run: npm publish --access public env: From bae4e43f59e3c6ee19c3860bd2f7fac5a4adfa50 Mon Sep 17 00:00:00 2001 From: Mikael Arvola Date: Wed, 21 Aug 2024 11:58:41 -0500 Subject: [PATCH 4/4] Update publish configuration Made the workflow use `npm ci`, added build as a prepack step, and added files to the package config. --- .github/workflows/publish_npm.yml | 7 +++---- template/package.json | 13 +++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml index 529d9af..70d0cdf 100644 --- a/.github/workflows/publish_npm.yml +++ b/.github/workflows/publish_npm.yml @@ -13,10 +13,9 @@ jobs: with: node-version: '22.x' registry-url: 'https://registry.npmjs.org' - - run: npm install - - run: npm rebuild - - run: npm run-script build - - name: Install to npm + - name: Install dependencies + run: npm ci + - name: Publish to npm run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.TOOLKIT_NPM_SECRET}} diff --git a/template/package.json b/template/package.json index f0e69e9..1be7c7d 100644 --- a/template/package.json +++ b/template/package.json @@ -6,15 +6,24 @@ "license": "MIT", "version": "0.0.1", "type": "module", + "files": [ + "src/**", + "dist/**", + "builder/**" + ], "exports": { ".": { - "import": "./src/<%= name %>.js" + "import": "./src/<%= name %>.js", + "require": "./dist/<%= name %>.cjs", + "default": "./dist/<%= name %>.js" } }, + "main":"./dist/<%= name %>.js", "scripts": { "dev": "vite", "build": "vite build --config vite.build.config.js --emptyOutDir", - "preview": "vite preview" + "preview": "vite preview", + "prepack": "npm run build" }, "dependencies": { "lit": "3.1.3"