Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 43 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
deno-version: v2.x

- name: Generate GraphQL code
run: deno task codegen
run: |
deno task codegen
sed -i "s|from './graphql';|from './graphql.ts';|g" src/__codegen__/gql.ts

- name: Check formatting
run: deno fmt --check
Expand All @@ -28,3 +30,43 @@ jobs:

- name: Run tests
run: deno task test

npm-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Generate GraphQL code
run: |
deno task codegen
sed -i "s|from './graphql';|from './graphql.ts';|g" src/__codegen__/gql.ts

- name: Build npm package
run: deno run -A scripts/build_npm.ts

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Test with npm
run: |
cd npm
npm install
npx linear --help

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Test with bun
run: |
cd npm
rm -rf node_modules bun.lockb
bun install
bun run esm/src/main.js --help
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.config/linear.toml

src/__codegen__/
/npm/
node_modules/
3 changes: 3 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import type { CodegenConfig } from "@graphql-codegen/cli"
const config: CodegenConfig = {
schema: "graphql/schema.graphql",
documents: ["src/**/*.ts"],
importExtension: ".ts",
generates: {
"src/__codegen__/": {
preset: "client",
plugins: [],
config: {
enumsAsTypes: true,
useTypeImports: true,
},
presetConfig: {
gqlTagName: "gql",
fragmentMasking: false,
importExtension: ".ts",
},
},
},
Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@cliffy/internal": "jsr:@cliffy/internal@^1.0.0-rc.8",
"@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.8",
"@cliffy/testing": "jsr:@cliffy/testing@^1.0.0-rc.8",
"@deno/dnt": "jsr:@deno/[email protected]",
"@graphql-codegen/cli": "npm:@graphql-codegen/cli@^5.0.7",
"@graphql-typed-document-node/core": "npm:@graphql-typed-document-node/core@^3.2.0",
"@littletof/charmd": "jsr:@littletof/charmd@^0.1.2",
Expand Down
101 changes: 98 additions & 3 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions scripts/build_npm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env -S deno run -A
import { build, emptyDir } from "@deno/dnt"
import denoConfig from "../deno.json" with { type: "json" }

await emptyDir("./npm")

await build({
entryPoints: ["./src/main.ts"],
outDir: "./npm",
shims: {
deno: true,
},
scriptModule: false, // ESM only (needed for top-level await)
typeCheck: false,
test: false,
package: {
name: "@schpet/linear-cli",
version: denoConfig.version,
description: "CLI tool for linear.app",
license: "MIT",
repository: {
type: "git",
url: "git+https://github.com/schpet/linear-cli.git",
},
bugs: {
url: "https://github.com/schpet/linear-cli/issues",
},
bin: {
linear: "./esm/src/main.js",
},
keywords: ["linear", "cli", "productivity"],
},
async postBuild() {
// Copy the README
Deno.copyFileSync("README.md", "npm/README.md")

// Create .npmrc to configure JSR registry for @jsr scope
await Deno.writeTextFile(
"npm/.npmrc",
"@jsr:registry=https://npm.jsr.io\n",
)

// Add shebang to the binary entry point
const mainPath = "npm/esm/src/main.js"
const mainContent = await Deno.readTextFile(mainPath)
await Deno.writeTextFile(mainPath, `#!/usr/bin/env node\n${mainContent}`)

// Add JSR dependencies to package.json using npm mirror (@jsr/ scope)
// This works with npm, pnpm, yarn, and bun
const pkgJsonPath = "npm/package.json"
const pkgJson = JSON.parse(await Deno.readTextFile(pkgJsonPath))
pkgJson.dependencies = {
...pkgJson.dependencies,
"@cliffy/ansi": "npm:@jsr/cliffy__ansi@^1.0.0-rc.8",
"@cliffy/command": "npm:@jsr/cliffy__command@^1.0.0-rc.8",
"@cliffy/prompt": "npm:@jsr/cliffy__prompt@^1.0.0-rc.8",
"@littletof/charmd": "npm:@jsr/littletof__charmd@^0.1.2",
"@opensrc/deno-open": "npm:@jsr/opensrc__deno-open@^1.0.0",
"@std/assert": "npm:@jsr/std__assert@^1.0.0",
"@std/cli": "npm:@jsr/std__cli@^1.0.0",
"@std/dotenv": "npm:@jsr/std__dotenv@^0.225.0",
"@std/encoding": "npm:@jsr/std__encoding@^1.0.0",
"@std/fmt": "npm:@jsr/std__fmt@^1.0.0",
"@std/fs": "npm:@jsr/std__fs@^1.0.0",
"@std/path": "npm:@jsr/std__path@^1.0.0",
"@std/toml": "npm:@jsr/std__toml@^1.0.0",
"@graphql-typed-document-node/core": "^3.2.0",
"graphql": "^16.8.1",
"graphql-request": "^7.2.0",
"open": "^10.0.0",
"sanitize-filename": "^1.6.3",
"unified": "^11.0.5",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
"unist-util-visit": "^5.0.0",
"valibot": "^1.2.0",
}
await Deno.writeTextFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
},
})