Skip to content

Commit

Permalink
[@typespec/compiler] Move compiler dependencies to peer and dev depen…
Browse files Browse the repository at this point in the history
…dencies
  • Loading branch information
sarangan12 committed Jul 12, 2024
1 parent ba65f90 commit f9e0cf5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
7 changes: 7 additions & 0 deletions packages/compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log - @typespec/compiler

## 0.58.0

### Bump dependencies

- [#3699](https://github.com/microsoft/typespec/pull/3699) Updated dependencies to peer and dev.


## 0.57.0


Expand Down
12 changes: 8 additions & 4 deletions packages/compiler/src/init/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,25 @@ async function writePackageJson(host: CompilerHost, config: ScaffoldingConfig) {
if (isFileSkipGeneration("package.json", config.template.files ?? [])) {
return;
}
const dependencies: Record<string, string> = {};
const peerDependencies: Record<string, string> = {};
const devDependencies: Record<string, string> = {};

if (!config.template.skipCompilerPackage) {
dependencies["@typespec/compiler"] = "latest";
peerDependencies["@typespec/compiler"] = "latest";
devDependencies["@typespec/compiler"] = "latest";
}

for (const library of config.libraries) {
dependencies[library.name] = await getLibraryVersion(library);
peerDependencies[library.name] = await getLibraryVersion(library);
devDependencies[library.name] = await getLibraryVersion(library);
}

const packageJson: NodePackage = {
name: config.name,
version: "0.1.0",
type: "module",
dependencies,
peerDependencies,
devDependencies,
private: true,
};

Expand Down
12 changes: 9 additions & 3 deletions packages/compiler/test/init/init-template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { deepStrictEqual, strictEqual } from "assert";
import { beforeEach, describe, it } from "vitest";
import { InitTemplate } from "../../src/init/init-template.js";
import {
makeScaffoldingConfig,
ScaffoldingConfig,
makeScaffoldingConfig,
scaffoldNewProject,
} from "../../src/init/scaffold.js";
import { createTestHost, resolveVirtualPath, TestHost } from "../../src/testing/index.js";
import { TestHost, createTestHost, resolveVirtualPath } from "../../src/testing/index.js";

describe("compiler: init: templates", () => {
let testHost: TestHost;
Expand Down Expand Up @@ -44,7 +44,13 @@ describe("compiler: init: templates", () => {
libraries: [{ name: "foo", version: "~1.2.3" }, { name: "bar" }],
});

deepStrictEqual(JSON.parse(getOutputFile("package.json")!).dependencies, {
deepStrictEqual(JSON.parse(getOutputFile("package.json")!).peerDependencies, {
"@typespec/compiler": "latest",
foo: "~1.2.3",
bar: "latest",
});

deepStrictEqual(JSON.parse(getOutputFile("package.json")!).devDependencies, {
"@typespec/compiler": "latest",
foo: "~1.2.3",
bar: "latest",
Expand Down

0 comments on commit f9e0cf5

Please sign in to comment.