diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..c8950c7 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,32 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to NPM in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/sfcompute/nodes-typescript/actions/workflows/publish-npm.yml +name: Publish NPM +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies + run: | + yarn install + + - name: Publish to NPM + run: | + bash ./bin/publish-npm + env: + NPM_TOKEN: ${{ secrets.SFC_NODES_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 084643a..cefda72 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -18,3 +18,4 @@ jobs: run: | bash ./bin/check-release-environment env: + NPM_TOKEN: ${{ secrets.SFC_NODES_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d7a8735..c5e8a3e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.1" + ".": "0.1.0-alpha.2" } diff --git a/.stats.yml b/.stats.yml index 420b13b..adb8762 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company%2Fsfc-nodes-b800806859333bacc88fa4236eae35c8cdbec62970b7fb9ad440a330f24a1622.yml openapi_spec_hash: fa672b6ca8953a8059961a7559a607a9 -config_hash: e089259785c0c81187a2b25ae04b8459 +config_hash: e310f0f1f4275f17d4a3872005f33a90 diff --git a/CHANGELOG.md b/CHANGELOG.md index b79d421..bbef375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.2 (2025-07-22) + +Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/sfcompute/nodes-typescript/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) + +### Chores + +* update SDK settings ([8db0e2d](https://github.com/sfcompute/nodes-typescript/commit/8db0e2dbb16e522c0e6e8970b5e2f1ddf5ee7f6f)) + ## 0.1.0-alpha.1 (2025-07-17) Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/sfcompute/nodes-typescript/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2150209..5134004 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,12 +55,12 @@ $ cd nodes-typescript # With yarn $ yarn link $ cd ../my-package -$ yarn link sfc-nodes +$ yarn link @sfc/nodes-sdk-alpha # With pnpm $ pnpm link --global $ cd ../my-package -$ pnpm link -—global sfc-nodes +$ pnpm link -—global @sfc/nodes-sdk-alpha ``` ## Running tests @@ -91,3 +91,17 @@ To format and fix all lint issues automatically: ```sh $ yarn fix ``` + +## Publishing and releases + +Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If +the changes aren't made through the automated pipeline, you may want to make releases manually. + +### Publish with a GitHub workflow + +You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/sfcompute/nodes-typescript/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. + +### Publish manually + +If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on +the environment. diff --git a/README.md b/README.md index 2b64a9d..ef8ea16 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SFC Nodes TypeScript API Library -[![NPM version]()](https://npmjs.org/package/sfc-nodes) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/sfc-nodes) +[![NPM version]()](https://npmjs.org/package/@sfc/nodes-sdk-alpha) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@sfc/nodes-sdk-alpha) This library provides convenient access to the SFC Nodes REST API from server-side TypeScript or JavaScript. @@ -11,19 +11,16 @@ It is generated with [Stainless](https://www.stainless.com/). ## Installation ```sh -npm install git+ssh://git@github.com:sfcompute/nodes-typescript.git +npm install @sfc/nodes-sdk-alpha ``` -> [!NOTE] -> Once this package is [published to npm](https://www.stainless.com/docs/guides/publish), this will become: `npm install sfc-nodes` - ## Usage The full API of this library can be found in [api.md](api.md). ```js -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ apiKey: process.env['SFC_API_KEY'], // This is the default and can be omitted @@ -38,7 +35,7 @@ This library includes TypeScript definitions for all request params and response ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ apiKey: process.env['SFC_API_KEY'], // This is the default and can be omitted @@ -160,7 +157,7 @@ The log level can be configured in two ways: 2. Using the `logLevel` client option (overrides the environment variable if set) ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ logLevel: 'debug', // Show all log messages @@ -188,7 +185,7 @@ When providing a custom logger, the `logLevel` option still controls which messa below the configured level will not be sent to your logger. ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; import pino from 'pino'; const logger = pino(); @@ -257,7 +254,7 @@ globalThis.fetch = fetch; Or pass it to the client: ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; import fetch from 'my-fetch'; const client = new SFCNodes({ fetch }); @@ -268,7 +265,7 @@ const client = new SFCNodes({ fetch }); 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.) ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ fetchOptions: { @@ -285,7 +282,7 @@ options to requests: **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)] ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; import * as undici from 'undici'; const proxyAgent = new undici.ProxyAgent('http://localhost:8888'); @@ -299,7 +296,7 @@ const client = new SFCNodes({ **Bun** [[docs](https://bun.sh/guides/http/proxy)] ```ts -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ fetchOptions: { @@ -311,7 +308,7 @@ const client = new SFCNodes({ **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)] ```ts -import SFCNodes from 'npm:sfc-nodes'; +import SFCNodes from 'npm:@sfc/nodes-sdk-alpha'; const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } }); const client = new SFCNodes({ diff --git a/bin/check-release-environment b/bin/check-release-environment index 6b43775..e4b6d58 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -2,6 +2,10 @@ errors=() +if [ -z "${NPM_TOKEN}" ]; then + errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + lenErrors=${#errors[@]} if [[ lenErrors -gt 0 ]]; then diff --git a/eslint.config.mjs b/eslint.config.mjs index 3ceb4dd..c6dce08 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -25,7 +25,7 @@ export default tseslint.config( { patterns: [ { - regex: '^sfc-nodes(/.*)?', + regex: '^@sfc/nodes-sdk-alpha(/.*)?', message: 'Use a relative import, not a package import.', }, ], diff --git a/jest.config.ts b/jest.config.ts index 7283568..4c197c9 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = { '^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }], }, moduleNameMapper: { - '^sfc-nodes$': '/src/index.ts', - '^sfc-nodes/(.*)$': '/src/$1', + '^@sfc/nodes-sdk-alpha$': '/src/index.ts', + '^@sfc/nodes-sdk-alpha/(.*)$': '/src/$1', }, modulePathIgnorePatterns: [ '/ecosystem-tests/', diff --git a/package.json b/package.json index eaa794a..8576eaa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "sfc-nodes", - "version": "0.1.0-alpha.1", + "name": "@sfc/nodes-sdk-alpha", + "version": "0.1.0-alpha.2", "description": "The official TypeScript library for the SFC Nodes API", "author": "SFC Nodes ", "types": "dist/index.d.ts", @@ -47,8 +47,8 @@ "typescript-eslint": "8.31.1" }, "imports": { - "sfc-nodes": ".", - "sfc-nodes/*": "./src/*" + "@sfc/nodes-sdk-alpha": ".", + "@sfc/nodes-sdk-alpha/*": "./src/*" }, "exports": { ".": { diff --git a/scripts/build b/scripts/build index 4fb311c..c7dcba6 100755 --- a/scripts/build +++ b/scripts/build @@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs # Build into dist and will publish the package from there, # so that src/resources/foo.ts becomes /resources/foo.js -# This way importing from `"sfc-nodes/resources/foo"` works +# This way importing from `"@sfc/nodes-sdk-alpha/resources/foo"` works # even with `"moduleResolution": "node"` rm -rf dist; mkdir dist @@ -42,8 +42,8 @@ node scripts/utils/postprocess-files.cjs # make sure that nothing crashes when we require the output CJS or # import the output ESM -(cd dist && node -e 'require("sfc-nodes")') -(cd dist && node -e 'import("sfc-nodes")' --input-type=module) +(cd dist && node -e 'require("@sfc/nodes-sdk-alpha")') +(cd dist && node -e 'import("@sfc/nodes-sdk-alpha")' --input-type=module) if [ -e ./scripts/build-deno ] then diff --git a/src/version.ts b/src/version.ts index b0bfd9e..a528f63 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-alpha.1'; // x-release-please-version +export const VERSION = '0.1.0-alpha.2'; // x-release-please-version diff --git a/tests/api-resources/nodes.test.ts b/tests/api-resources/nodes.test.ts index ec4b4b2..48a7ae5 100644 --- a/tests/api-resources/nodes.test.ts +++ b/tests/api-resources/nodes.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ apiKey: 'My API Key', diff --git a/tests/api-resources/vms/script.test.ts b/tests/api-resources/vms/script.test.ts index 9483cd1..ca85364 100644 --- a/tests/api-resources/vms/script.test.ts +++ b/tests/api-resources/vms/script.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ apiKey: 'My API Key', diff --git a/tests/api-resources/vms/vms.test.ts b/tests/api-resources/vms/vms.test.ts index 80dd9e6..c3fa186 100644 --- a/tests/api-resources/vms/vms.test.ts +++ b/tests/api-resources/vms/vms.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import SFCNodes from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; const client = new SFCNodes({ apiKey: 'My API Key', diff --git a/tests/base64.test.ts b/tests/base64.test.ts index 99c2802..4bd8156 100644 --- a/tests/base64.test.ts +++ b/tests/base64.test.ts @@ -1,4 +1,4 @@ -import { fromBase64, toBase64 } from 'sfc-nodes/internal/utils/base64'; +import { fromBase64, toBase64 } from '@sfc/nodes-sdk-alpha/internal/utils/base64'; describe.each(['Buffer', 'atob'])('with %s', (mode) => { let originalBuffer: BufferConstructor; diff --git a/tests/buildHeaders.test.ts b/tests/buildHeaders.test.ts index e492b0c..2263f6c 100644 --- a/tests/buildHeaders.test.ts +++ b/tests/buildHeaders.test.ts @@ -1,5 +1,5 @@ import { inspect } from 'node:util'; -import { buildHeaders, type HeadersLike, type NullableHeaders } from 'sfc-nodes/internal/headers'; +import { buildHeaders, type HeadersLike, type NullableHeaders } from '@sfc/nodes-sdk-alpha/internal/headers'; function inspectNullableHeaders(headers: NullableHeaders) { return `NullableHeaders {${[ diff --git a/tests/form.test.ts b/tests/form.test.ts index 39daf06..3e902a6 100644 --- a/tests/form.test.ts +++ b/tests/form.test.ts @@ -1,5 +1,5 @@ -import { multipartFormRequestOptions, createForm } from 'sfc-nodes/internal/uploads'; -import { toFile } from 'sfc-nodes/core/uploads'; +import { multipartFormRequestOptions, createForm } from '@sfc/nodes-sdk-alpha/internal/uploads'; +import { toFile } from '@sfc/nodes-sdk-alpha/core/uploads'; describe('form data validation', () => { test('valid values do not error', async () => { diff --git a/tests/index.test.ts b/tests/index.test.ts index 68f5366..1e10f65 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { APIPromise } from 'sfc-nodes/core/api-promise'; +import { APIPromise } from '@sfc/nodes-sdk-alpha/core/api-promise'; import util from 'node:util'; -import SFCNodes from 'sfc-nodes'; -import { APIUserAbortError } from 'sfc-nodes'; +import SFCNodes from '@sfc/nodes-sdk-alpha'; +import { APIUserAbortError } from '@sfc/nodes-sdk-alpha'; const defaultFetch = fetch; describe('instantiate client', () => { diff --git a/tests/path.test.ts b/tests/path.test.ts index 3d80925..f48ddc7 100644 --- a/tests/path.test.ts +++ b/tests/path.test.ts @@ -1,4 +1,4 @@ -import { createPathTagFunction, encodeURIPath } from 'sfc-nodes/internal/utils/path'; +import { createPathTagFunction, encodeURIPath } from '@sfc/nodes-sdk-alpha/internal/utils/path'; import { inspect } from 'node:util'; import { runInNewContext } from 'node:vm'; diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 7380bee..949a067 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { SFCNodes } from 'sfc-nodes'; +import { SFCNodes } from '@sfc/nodes-sdk-alpha'; const { stringifyQuery } = SFCNodes.prototype as any; diff --git a/tests/uploads.test.ts b/tests/uploads.test.ts index 1e15cec..ecccf64 100644 --- a/tests/uploads.test.ts +++ b/tests/uploads.test.ts @@ -1,6 +1,6 @@ import fs from 'fs'; -import type { ResponseLike } from 'sfc-nodes/internal/to-file'; -import { toFile } from 'sfc-nodes/core/uploads'; +import type { ResponseLike } from '@sfc/nodes-sdk-alpha/internal/to-file'; +import { toFile } from '@sfc/nodes-sdk-alpha/core/uploads'; import { File } from 'node:buffer'; class MyClass { @@ -97,7 +97,7 @@ describe('missing File error message', () => { }); test('is thrown', async () => { - const uploads = await import('sfc-nodes/core/uploads'); + const uploads = await import('@sfc/nodes-sdk-alpha/core/uploads'); await expect( uploads.toFile(mockResponse({ url: 'https://example.com/my/audio.mp3' })), ).rejects.toMatchInlineSnapshot( diff --git a/tsconfig.build.json b/tsconfig.build.json index 9d95f3d..79c685f 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "sfc-nodes/*": ["dist/src/*"], - "sfc-nodes": ["dist/src/index.ts"] + "@sfc/nodes-sdk-alpha/*": ["dist/src/*"], + "@sfc/nodes-sdk-alpha": ["dist/src/index.ts"] }, "noEmit": false, "declaration": true, diff --git a/tsconfig.json b/tsconfig.json index 5f660a0..c903d30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,8 +9,8 @@ "esModuleInterop": true, "baseUrl": "./", "paths": { - "sfc-nodes/*": ["src/*"], - "sfc-nodes": ["src/index.ts"] + "@sfc/nodes-sdk-alpha/*": ["src/*"], + "@sfc/nodes-sdk-alpha": ["src/index.ts"] }, "noEmit": true,