-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generator emits cjs #1138
Generator emits cjs #1138
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@osdk/foundry-sdk-generator": minor | ||
--- | ||
|
||
We now generate osdk libs that support commonjs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export { completeTodo } from './actions/completeTodo'; | ||
export { createOffice } from './actions/createOffice'; | ||
export { createOfficeAndEmployee } from './actions/createOfficeAndEmployee'; | ||
export { createTodo } from './actions/createTodo'; | ||
export { moveOffice } from './actions/moveOffice'; | ||
export { promoteEmployee } from './actions/promoteEmployee'; | ||
export { promoteEmployeeObject } from './actions/promoteEmployeeObject'; | ||
export { completeTodo } from './actions/completeTodo.js'; | ||
export { createOffice } from './actions/createOffice.js'; | ||
export { createOfficeAndEmployee } from './actions/createOfficeAndEmployee.js'; | ||
export { createTodo } from './actions/createTodo.js'; | ||
export { moveOffice } from './actions/moveOffice.js'; | ||
export { promoteEmployee } from './actions/promoteEmployee.js'; | ||
export { promoteEmployeeObject } from './actions/promoteEmployeeObject.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { Employee } from './objects/Employee'; | ||
export { equipment } from './objects/equipment'; | ||
export { Office } from './objects/Office'; | ||
export { Todo } from './objects/Todo'; | ||
export { Employee } from './objects/Employee.js'; | ||
export { equipment } from './objects/equipment.js'; | ||
export { Office } from './objects/Office.js'; | ||
export { Todo } from './objects/Todo.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export { completeTodo, createTodo } from './ontology/actions'; | ||
export * as $Actions from './ontology/actions'; | ||
export {} from './ontology/interfaces'; | ||
export * as $Interfaces from './ontology/interfaces'; | ||
export { Todo } from './ontology/objects'; | ||
export * as $Objects from './ontology/objects'; | ||
export {} from './ontology/queries'; | ||
export * as $Queries from './ontology/queries'; | ||
export { $osdkMetadata } from './OntologyMetadata'; | ||
export { $ontologyRid } from './OntologyMetadata'; | ||
export { completeTodo, createTodo } from './ontology/actions.js'; | ||
export * as $Actions from './ontology/actions.js'; | ||
export {} from './ontology/interfaces.js'; | ||
export * as $Interfaces from './ontology/interfaces.js'; | ||
export { Todo } from './ontology/objects.js'; | ||
export * as $Objects from './ontology/objects.js'; | ||
export {} from './ontology/queries.js'; | ||
export * as $Queries from './ontology/queries.js'; | ||
export { $osdkMetadata } from './OntologyMetadata.js'; | ||
export { $ontologyRid } from './OntologyMetadata.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { completeTodo } from './actions/completeTodo'; | ||
export { createTodo } from './actions/createTodo'; | ||
export { completeTodo } from './actions/completeTodo.js'; | ||
export { createTodo } from './actions/createTodo.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { Todo } from './objects/Todo'; | ||
export { Todo } from './objects/Todo.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import { | |
createProgram, | ||
createSourceFile, | ||
ModuleKind, | ||
ModuleResolutionKind, | ||
ScriptTarget, | ||
} from "typescript"; | ||
|
||
|
@@ -31,6 +30,7 @@ export interface CompilerOutput { | |
|
||
export function compileInMemory( | ||
files: { [fileName: string]: string }, | ||
type: "cjs" | "esm", | ||
): { | ||
files: { | ||
[fileName: string]: string; | ||
|
@@ -39,9 +39,9 @@ export function compileInMemory( | |
} { | ||
const inMemoryOutputFileSystem: { [fileName: string]: string } = {}; | ||
const compilerOptions: CompilerOptions = { | ||
module: ModuleKind.NodeNext, | ||
module: type === "cjs" ? ModuleKind.CommonJS : ModuleKind.ES2022, | ||
target: ScriptTarget.ES2020, | ||
moduleResolution: ModuleResolutionKind.NodeNext, | ||
resolvePackageJsonExports: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you have to explicitly set this now because you're not specifying moduleResolution anymore? More concretely, if module is CommonJS, then moduleResolution becomes node10, in which case, it wont look at exports by default. But if its ES2022, then technically you don't need to explicitly set that line right cuz it'll default on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. So I want to be sure we are generating in a way that will work with Node16 so I turn this on. |
||
declaration: true, | ||
skipLibCheck: true, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,21 +42,29 @@ export async function generatePackageJson(options: { | |
const packageJson = { | ||
name: options.packageName, | ||
version: options.packageVersion, | ||
main: "./index.js", | ||
types: "./index.d.ts", | ||
main: "./cjs/index.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So are these two fields cjs now because node10 default looks at the main field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
types: "./cjs/index.d.ts", | ||
exports: { | ||
".": { | ||
types: "./index.d.ts", | ||
script: { | ||
types: "./dist/bundle/index.d.ts", | ||
default: "./dist/bundle/index.esm.js", | ||
types: "./dist/bundle/index.d.mts", | ||
default: "./dist/bundle/index.mjs", | ||
}, | ||
default: "./index.js", | ||
require: { | ||
types: "./cjs/index.d.ts", | ||
default: "./cjs/index.js", | ||
}, | ||
import: { | ||
types: "./esm/index.d.ts", | ||
default: "./esm/index.js", | ||
}, | ||
types: "./cjs/index.d.ts", | ||
default: "./cjs/index.js", | ||
}, | ||
}, | ||
dependencies: packageDeps, | ||
peerDependencies: packagePeerDeps, | ||
type: "module", | ||
type: "commonjs", | ||
}; | ||
|
||
await writeFile( | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
// @ts-check | ||
import { generateWithMockOntology } from "../build/esm/generateWithMockOntology.js"; | ||
await generateWithMockOntology(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "@osdk/tool.generate-with-mock-ontology", | ||
"private": true, | ||
"version": "0.0.1", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/palantir/osdk-ts.git" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./build/types/index.d.ts", | ||
"default": "./build/esm/index.js" | ||
}, | ||
"default": "./build/esm/index.js" | ||
}, | ||
"./*": { | ||
"import": { | ||
"types": "./build/types/public/*.d.ts", | ||
"default": "./build/esm/public/*.js" | ||
}, | ||
"default": "./build/esm/public/*.js" | ||
} | ||
}, | ||
"scripts": { | ||
"check-spelling": "cspell --quiet .", | ||
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo", | ||
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)", | ||
"lint": "eslint . && dprint check --config $(find-up dprint.json)", | ||
"transpileEsm": "monorepo.tool.transpile -f esm -m normal -t node", | ||
"transpileTypes": "monorepo.tool.transpile -f esm -m types -t node", | ||
"typecheck": "tsc --noEmit --emitDeclarationOnly false" | ||
}, | ||
"dependencies": { | ||
"@osdk/api": "workspace:~", | ||
"@osdk/client": "workspace:~", | ||
"@test-app2/osdk": "link:./osdk/@test-app2/osdk" | ||
}, | ||
"devDependencies": { | ||
"@osdk/foundry-sdk-generator": "workspace:~", | ||
"@osdk/monorepo.api-extractor": "workspace:~", | ||
"@osdk/monorepo.tsconfig": "workspace:~", | ||
"@osdk/shared.test": "workspace:~", | ||
"execa": "^9.5.1", | ||
"typescript": "~5.5.4" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bin": { | ||
"generate-with-mock-ontology": "./bin/generate-with-mock-ontology.mjs" | ||
}, | ||
"files": [ | ||
"build/esm", | ||
"build/types", | ||
"CHANGELOG.md", | ||
"package.json", | ||
"templates", | ||
"*.d.ts" | ||
], | ||
"module": "./build/esm/index.js", | ||
"type": "module" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// @ts-check | ||
import { __testSeamOnly_NotSemverStable__GeneratePackageCommand as GeneratePackageCommand } from "@osdk/foundry-sdk-generator"; | ||
import { apiServer } from "@osdk/shared.test"; | ||
import { $ } from "execa"; | ||
import * as fs from "node:fs/promises"; | ||
import { tmpdir } from "node:os"; | ||
import * as path from "node:path"; | ||
import { safeStat } from "./safeStat.js"; | ||
|
||
export async function generateWithMockOntology(): Promise<void> { | ||
try { | ||
const dir = await fs.mkdtemp( | ||
path.join(tmpdir(), "osdk-e2e-foundry-sdk-generator-"), | ||
); | ||
|
||
apiServer.listen(); | ||
|
||
const testApp2Dir = path.join(dir, "@test-app2"); | ||
|
||
await fs.rm(testApp2Dir, { recursive: true, force: true }); | ||
await safeStat(testApp2Dir, "should not exist"); | ||
|
||
await fs.mkdir(dir, { recursive: true }); | ||
|
||
const generatePackageCommand = new GeneratePackageCommand(); | ||
|
||
const baseArgs: Parameters<typeof generatePackageCommand["handler"]>[0] = { | ||
packageName: "@test-app2/osdk", | ||
packageVersion: "0.0.1", | ||
outputDir: dir, | ||
authToken: "myAccessToken", | ||
foundryHostname: "https://stack.palantir.com", | ||
ontology: | ||
"ri.ontology.main.ontology.698267cc-6b48-4d98-beff-29beb24e9361", | ||
objectTypes: [ | ||
"Employee", | ||
"Office", | ||
"objectTypeWithAllPropertyTypes", | ||
"ObjectWithTimestampPrimaryKey", | ||
"equipment", | ||
], | ||
actionTypes: [ | ||
"createOffice", | ||
"moveOffice", | ||
"createOfficeAndEmployee", | ||
"actionTakesObjectSet", | ||
], | ||
queryTypes: [ | ||
"addOne", | ||
"incrementPersonAge", | ||
"returnsTimestamp", | ||
"returnsDate", | ||
"returnsObject", | ||
"twoDimensionalAggregationFunction", | ||
"threeDimensionalAggregationFunction", | ||
], | ||
interfaceTypes: [ | ||
"FooInterface", | ||
], | ||
linkTypes: ["employee.peeps", "employee.lead", "employee.officeLink"], | ||
palantirOnlyTest: true, | ||
_: [], | ||
$0: "", | ||
}; | ||
|
||
await generatePackageCommand.handler({ | ||
...baseArgs, | ||
packageName: "@test-app2/osdk", | ||
beta: false, | ||
}); | ||
|
||
await safeStat(testApp2Dir, "should exist"); | ||
|
||
await $({ | ||
stdout: "inherit", | ||
stderr: "inherit", | ||
})`attw --pack ${ | ||
path.join(testApp2Dir, "osdk") | ||
} --ignore-rules internal-resolution-error`; | ||
|
||
const finalOutDir = path.join( | ||
process.cwd(), | ||
"osdk", | ||
); | ||
|
||
await fs.rm(path.join(finalOutDir, "@test-app2"), { | ||
recursive: true, | ||
force: true, | ||
}); | ||
await fs.cp(dir, finalOutDir, { recursive: true }); | ||
} finally { | ||
// eslint-disable-next-line no-console | ||
console.log("teardown: stopping API server"); | ||
apiServer.close(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2025 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export { generateWithMockOntology } from "./generateWithMockOntology.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2025 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { Stats } from "node:fs"; | ||
import * as fs from "node:fs/promises"; | ||
|
||
export async function safeStat( | ||
filePath: string, | ||
type?: "should exist" | "should not exist", | ||
): Promise<Stats | undefined> { | ||
try { | ||
const ret = await fs.stat(filePath); | ||
if (type === "should not exist") { | ||
throw new Error(`Expected ${filePath} to not exist`); | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(`safeStat: ${filePath} exists`); | ||
return ret; | ||
} catch (e) { | ||
if (type === "should exist") { | ||
throw new Error(`Expected ${filePath} to exist`); | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(`safeStat: ${filePath} does not exist`); | ||
return undefined; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "@osdk/monorepo.tsconfig/base.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build/esm" | ||
}, | ||
"include": [ | ||
"./src/**/*" | ||
], | ||
"references": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2023 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { configDefaults, defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
pool: "forks", | ||
exclude: [...configDefaults.exclude, "**/build/**/*"], | ||
fakeTimers: { | ||
toFake: ["setTimeout", "clearTimeout", "Date"], | ||
}, | ||
}, | ||
}); |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/osdk/* | ||
!/osdk/.gitkeep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@osdk/tests.verify-cjs-node10", | ||
"private": true, | ||
"version": "0.0.3", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/palantir/osdk-ts.git" | ||
}, | ||
"scripts": { | ||
"codegen": "generate-with-mock-ontology", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@osdk/api": "workspace:~", | ||
"@osdk/client": "workspace:~", | ||
"@test-app2/osdk": "link:./osdk/@test-app2/osdk" | ||
}, | ||
"devDependencies": { | ||
"@osdk/tool.generate-with-mock-ontology": "workspace:~", | ||
"typescript": "~5.5.4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as Client from "@osdk/client"; | ||
import * as sdk from "@test-app2/osdk"; | ||
Client.createClient({} as any, "", async () => ""); | ||
|
||
import * as Api from "@osdk/api"; | ||
type Q = Api.InterfaceMetadata; | ||
|
||
import * as Unstable from "@osdk/client/unstable-do-not-use"; | ||
Unstable.augment({ type: "object", apiName: "foo" } as any); | ||
|
||
if (sdk.$Objects.Employee.apiName !== "Employee") { | ||
throw new Error("Expected Employee"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"moduleResolution": "node10", | ||
"target": "es2020", | ||
"skipLibCheck": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": ["//"], | ||
"tasks": { | ||
"codegen": { | ||
"outputs": ["osdk/@test-app2/**/*"], | ||
"dependsOn": [ | ||
"@osdk/tool.generate-with-mock-ontology#transpile", | ||
"^transpile" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/osdk/* | ||
!/osdk/.gitkeep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import * as Client from "@osdk/client"; | ||
import * as sdk from "@test-app2/osdk"; | ||
Client.createClient({} as any, "", async () => ""); | ||
|
||
import * as Api from "@osdk/api"; | ||
type Q = Api.InterfaceMetadata; | ||
|
||
import * as Unstable from "@osdk/client/unstable-do-not-use"; | ||
Unstable.augment({ type: "object", apiName: "foo" } as any); | ||
|
||
if (sdk.$Objects.Employee.apiName !== "Employee") { | ||
throw new Error("Expected Employee"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": ["//"], | ||
"tasks": { | ||
"codegen": { | ||
"outputs": ["osdk/@test-app2/**/*"], | ||
"dependsOn": [ | ||
"@osdk/tool.generate-with-mock-ontology#transpile", | ||
"^transpile" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/osdk/* | ||
!/osdk/.gitkeep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@osdk/tests.verify-esm-node16", | ||
"private": true, | ||
"version": "0.0.3", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/palantir/osdk-ts.git" | ||
}, | ||
"scripts": { | ||
"codegen": "generate-with-mock-ontology", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@osdk/api": "workspace:~", | ||
"@osdk/client": "workspace:~", | ||
"@test-app2/osdk": "link:./osdk/@test-app2/osdk" | ||
}, | ||
"devDependencies": { | ||
"@osdk/tool.generate-with-mock-ontology": "workspace:~", | ||
"typescript": "~5.5.4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as Client from "@osdk/client"; | ||
import * as sdk from "@test-app2/osdk"; | ||
Client.createClient({} as any, "", async () => ""); | ||
|
||
import * as Api from "@osdk/api"; | ||
type Q = Api.InterfaceMetadata; | ||
|
||
import * as Unstable from "@osdk/client/unstable-do-not-use"; | ||
Unstable.augment({ type: "object", apiName: "foo" } as any); | ||
|
||
if (sdk.$Objects.Employee.apiName !== "Employee") { | ||
throw new Error("Expected Employee"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "node16", | ||
"moduleResolution": "node16", | ||
"target": "es2020", | ||
"skipLibCheck": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": ["//"], | ||
"tasks": { | ||
"codegen": { | ||
"outputs": ["osdk/@test-app2/**/*"], | ||
"dependsOn": [ | ||
"@osdk/tool.generate-with-mock-ontology#transpile", | ||
"^transpileCjs" | ||
] | ||
} | ||
} | ||
} |
Unchanged files with check annotations Beta
this.errorCode = errorCode; | ||
this.statusCode = statusCode; | ||
this.errorInstanceId = errorInstanceId; | ||
this.parameters = parameters; | ||
Check warning on line 39 in packages/shared.net.errors/src/PalantirApiError.ts
|
||
} | ||
} |
const sourcePackageJsonPath = await findUp("package.json"); | ||
if (!sourcePackageJsonPath) throw new Error("package.json is missing"); | ||
const sourcePackageJson = JSON.parse( | ||
Check warning on line 31 in packages/create-app.template-packager/src/index.ts
|
||
await fs.readFile(sourcePackageJsonPath, "utf-8"), | ||
); | ||
let output: string; | ||
if (destPath === "package.json.hbs") { | ||
const packageJson = JSON.parse(body.toString("utf-8")); | ||
Check warning on line 58 in packages/create-app.template-packager/src/index.ts
|
||
for ( | ||
const d of ["dependencies", "devDependencies", "peerDependencies"] | ||
) { | ||
if (sourcePackageJson[d]) { | ||
Check warning on line 63 in packages/create-app.template-packager/src/index.ts
|
||
if (!packageJson[d]) { | ||
Check warning on line 64 in packages/create-app.template-packager/src/index.ts
|
||
packageJson[d] = {}; | ||
Check warning on line 65 in packages/create-app.template-packager/src/index.ts
|
||
} | ||
Object.assign(packageJson[d], sourcePackageJson[d]); | ||
Check warning on line 67 in packages/create-app.template-packager/src/index.ts
|
||
delete packageJson[d]["@osdk/create-app.template-packager"]; | ||
Check warning on line 68 in packages/create-app.template-packager/src/index.ts
|
||
for (const key of Object.keys(packageJson[d])) { | ||
Check warning on line 69 in packages/create-app.template-packager/src/index.ts
|
||
if (key.startsWith("@osdk/monorepo.")) { | ||
delete packageJson[d][key]; | ||
} |
}); | ||
server.on("error", (e) => { | ||
if ((e as any).code === "EADDRINUSE") { | ||
consola.error( | ||
`Port ${port} is already in use, unable to perform authentication flow.`, | ||
); | ||
function generateRandomString(length = 128) { | ||
const characters = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; | ||
let output: string[] = []; | ||
let array = new Uint8Array(1); | ||
const maxIndex = 256 - (256 % characters.length); | ||
while (output.length < length) { | ||
method: "POST", | ||
}); | ||
const responseText: TokenResponse = await response.json(); | ||
return responseText; | ||
} catch (e) { | ||
throw new Error( | ||
`Failed to get token: ${ | ||
(e as { cause?: any })?.cause?.toString() ?? e?.toString() | ||
Check warning on line 198 in packages/cli.common/src/commands/auth/login/loginFlow.ts
|
||
?? "Unknown error" | ||
}`, | ||
); |
.demandCommand() | ||
.middleware(logLevelMiddleware, true) | ||
.strict() | ||
.fail(async (msg, err, argv) => { | ||
if (err instanceof ExitProcessError) { | ||
consola.error(err.message); | ||
if (err.tip != null) { | ||
} | ||
consola.debug(err.stack); | ||
} else { | ||
if (err && err instanceof YargsCheckError === false) { | ||
throw err; | ||
} else { | ||
argv.showHelp(); |
import type { CliCommonArgs } from "../CliCommonArgs.js"; | ||
let firstTime = true; | ||
export async function logLevelMiddleware(args: CliCommonArgs): Promise<void> { | ||
if (firstTime) { | ||
firstTime = false; | ||
it.each(["1.2.3", "~1.2.3", "^1.2.3"])( | ||
`replaces "%s" with "${expectedPrefix}1.2.3"`, | ||
async (version) => { | ||
const result = await changeVersionPrefix(version, expectedPrefix); | ||
expect(result).toEqual(`${expectedPrefix}1.2.3`); | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang our tests taking long now