Skip to content

Commit 5033f0f

Browse files
chore: update SDK settings (#3)
1 parent ee6938b commit 5033f0f

20 files changed

+88
-40
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
{
1111
patterns: [
1212
{
13-
group: ['lightswitch', 'lightswitch/*'],
13+
group: ['lightswitch-api', 'lightswitch-api/*'],
1414
message: 'Use a relative import, not a package import.',
1515
},
1616
],

.github/workflows/publish-npm.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow is triggered when a GitHub release is created.
2+
# It can also be run manually to re-publish to NPM in case it failed for some reason.
3+
# You can run this workflow by navigating to https://www.github.com/GitbookIO/lightswitch/actions/workflows/publish-npm.yml
4+
name: Publish NPM
5+
on:
6+
workflow_dispatch:
7+
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
publish:
13+
name: publish
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Node
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '18'
23+
24+
- name: Install dependencies
25+
run: |
26+
yarn install
27+
28+
- name: Publish to NPM
29+
run: |
30+
bash ./bin/publish-npm
31+
env:
32+
NPM_TOKEN: ${{ secrets.LIGHTSWITCH_NPM_TOKEN || secrets.NPM_TOKEN }}

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ jobs:
1818
run: |
1919
bash ./bin/check-release-environment
2020
env:
21+
NPM_TOKEN: ${{ secrets.LIGHTSWITCH_NPM_TOKEN || secrets.NPM_TOKEN }}
2122

CONTRIBUTING.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ $ cd lightswitch
5555
# With yarn
5656
$ yarn link
5757
$ cd ../my-package
58-
$ yarn link lightswitch
58+
$ yarn link lightswitch-api
5959

6060
# With pnpm
6161
$ pnpm link --global
6262
$ cd ../my-package
63-
$ pnpm link -—global lightswitch
63+
$ pnpm link -—global lightswitch-api
6464
```
6565

6666
## Running tests
@@ -91,3 +91,17 @@ To format and fix all lint issues automatically:
9191
```sh
9292
$ yarn fix
9393
```
94+
95+
## Publishing and releases
96+
97+
Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
98+
the changes aren't made through the automated pipeline, you may want to make releases manually.
99+
100+
### Publish with a GitHub workflow
101+
102+
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/GitbookIO/lightswitch/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.
103+
104+
### Publish manually
105+
106+
If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
107+
the environment.

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lightswitch TypeScript API Library
22

3-
[![NPM version](https://img.shields.io/npm/v/lightswitch.svg)](https://npmjs.org/package/lightswitch) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/lightswitch)
3+
[![NPM version](https://img.shields.io/npm/v/lightswitch-api.svg)](https://npmjs.org/package/lightswitch-api) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/lightswitch-api)
44

55
This library provides convenient access to the Lightswitch REST API from server-side TypeScript or JavaScript.
66

@@ -11,19 +11,16 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
1111
## Installation
1212

1313
```sh
14-
npm install git+ssh://[email protected]:GitbookIO/lightswitch.git
14+
npm install lightswitch-api
1515
```
1616

17-
> [!NOTE]
18-
> Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install lightswitch`
19-
2017
## Usage
2118

2219
The full API of this library can be found in [api.md](api.md).
2320

2421
<!-- prettier-ignore -->
2522
```js
26-
import Lightswitch from 'lightswitch';
23+
import Lightswitch from 'lightswitch-api';
2724

2825
const client = new Lightswitch();
2926

@@ -40,7 +37,7 @@ This library includes TypeScript definitions for all request params and response
4037

4138
<!-- prettier-ignore -->
4239
```ts
43-
import Lightswitch from 'lightswitch';
40+
import Lightswitch from 'lightswitch-api';
4441

4542
const client = new Lightswitch();
4643

@@ -223,7 +220,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
223220

224221
```ts
225222
import { fetch } from 'undici'; // as one example
226-
import Lightswitch from 'lightswitch';
223+
import Lightswitch from 'lightswitch-api';
227224

228225
const client = new Lightswitch({
229226
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
@@ -243,7 +240,7 @@ This is intended for debugging purposes only and may change in the future withou
243240
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
244241

245242
```ts
246-
import Lightswitch from 'lightswitch';
243+
import Lightswitch from 'lightswitch-api';
247244

248245
const client = new Lightswitch({
249246
fetchOptions: {
@@ -260,7 +257,7 @@ options to requests:
260257
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
261258

262259
```ts
263-
import Lightswitch from 'lightswitch';
260+
import Lightswitch from 'lightswitch-api';
264261
import * as undici from 'undici';
265262

266263
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
@@ -274,7 +271,7 @@ const client = new Lightswitch({
274271
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
275272

276273
```ts
277-
import Lightswitch from 'lightswitch';
274+
import Lightswitch from 'lightswitch-api';
278275

279276
const client = new Lightswitch({
280277
fetchOptions: {
@@ -286,7 +283,7 @@ const client = new Lightswitch({
286283
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
287284

288285
```ts
289-
import Lightswitch from 'npm:lightswitch';
286+
import Lightswitch from 'npm:lightswitch-api';
290287

291288
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
292289
const client = new Lightswitch({

bin/check-release-environment

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
errors=()
44

5+
if [ -z "${NPM_TOKEN}" ]; then
6+
errors+=("The LIGHTSWITCH_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
7+
fi
8+
59
lenErrors=${#errors[@]}
610

711
if [[ lenErrors -gt 0 ]]; then

jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = {
77
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
88
},
99
moduleNameMapper: {
10-
'^lightswitch$': '<rootDir>/src/index.ts',
11-
'^lightswitch/(.*)$': '<rootDir>/src/$1',
10+
'^lightswitch-api$': '<rootDir>/src/index.ts',
11+
'^lightswitch-api/(.*)$': '<rootDir>/src/$1',
1212
},
1313
modulePathIgnorePatterns: [
1414
'<rootDir>/ecosystem-tests/',

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "lightswitch",
2+
"name": "lightswitch-api",
33
"version": "0.0.1-alpha.0",
44
"description": "The official TypeScript library for the Lightswitch API",
55
"author": "Lightswitch <[email protected]>",
@@ -46,8 +46,8 @@
4646
"typescript": "^4.8.2"
4747
},
4848
"imports": {
49-
"lightswitch": ".",
50-
"lightswitch/*": "./src/*"
49+
"lightswitch-api": ".",
50+
"lightswitch-api/*": "./src/*"
5151
},
5252
"exports": {
5353
".": {

scripts/build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs
88

99
# Build into dist and will publish the package from there,
1010
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
11-
# This way importing from `"lightswitch/resources/foo"` works
11+
# This way importing from `"lightswitch-api/resources/foo"` works
1212
# even with `"moduleResolution": "node"`
1313

1414
rm -rf dist; mkdir dist
@@ -47,8 +47,8 @@ node scripts/utils/postprocess-files.cjs
4747

4848
# make sure that nothing crashes when we require the output CJS or
4949
# import the output ESM
50-
(cd dist && node -e 'require("lightswitch")')
51-
(cd dist && node -e 'import("lightswitch")' --input-type=module)
50+
(cd dist && node -e 'require("lightswitch-api")')
51+
(cd dist && node -e 'import("lightswitch-api")' --input-type=module)
5252

5353
if [ -e ./scripts/build-deno ]
5454
then

tests/api-resources/projects.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import Lightswitch from 'lightswitch';
3+
import Lightswitch from 'lightswitch-api';
44

55
const client = new Lightswitch({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
66

0 commit comments

Comments
 (0)