Skip to content

Commit

Permalink
add npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Dec 5, 2023
1 parent cde61ef commit 6399159
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

permissions:
contents: write
id-token: write

jobs:
release:
Expand All @@ -28,3 +29,14 @@ jobs:
run: cargo publish -p markup_fmt
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8.10.5
run_install: true
- name: Publish to npm
run: |
cp target/wasm32-unknown-unknown/release/dprint_plugin_markup.wasm dprint_plugin/deployment/npm/plugin.wasm
pnpm -F dprint-plugin-markup publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/target
node_modules/
pnpm-lock.yaml
*.js
*.d.ts
8 changes: 8 additions & 0 deletions dprint_plugin/deployment/npm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as path from 'node:path'
import * as URL from 'node:url'

export function getPath() {
return path.join(path.dirname(URL.fileURLToPath(import.meta.url)), 'plugin.wasm')
}

export type * from './config.js'
32 changes: 32 additions & 0 deletions dprint_plugin/deployment/npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "dprint-plugin-markup",
"description": "markup_fmt as dprint plugin.",
"version": "0.2.1",
"author": "Pig Fang <[email protected]>",
"repository": "g-plane/markup_fmt",
"license": "MIT",
"type": "module",
"keywords": [
"dprint",
"dprint-plugin"
],
"files": [
"*.wasm",
"*.js",
"*.d.ts"
],
"main": "index.js",
"exports": {
".": "./index.js"
},
"scripts": {
"build": "json2ts ../schema.json -o config.d.ts --no-additionalProperties && tsc -p .",
"prepublishOnly": "pnpm build"
},
"devDependencies": {
"@gplane/tsconfig": "^6.1.0",
"@types/node": "^20.10.3",
"json-schema-to-typescript": "^13.1.1",
"typescript": "^5.3.2"
}
}
6 changes: 6 additions & 0 deletions dprint_plugin/deployment/npm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@gplane/tsconfig",
"compilerOptions": {
"sourceMap": false
}
}
2 changes: 2 additions & 0 deletions dprint_plugin/deployment/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://plugins.dprint.dev/g-plane/markup_fmt/v0.2.1/schema.json",
"title": "Config",
"description": "Configuration for dprint-plugin-markup.",
"type": "object",
"properties": {
"printWidth": {
Expand Down
2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- dprint_plugin/deployment/npm

0 comments on commit 6399159

Please sign in to comment.