Skip to content

Commit 5075eae

Browse files
authoredJul 7, 2022
feat: add json schema for lerna.json (#3229)
1 parent 0e976bf commit 5075eae

File tree

7 files changed

+1848
-1
lines changed

7 files changed

+1848
-1
lines changed
 

‎commands/init/__tests__/init-command.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe("InitCommand", () => {
6666
await lernaInit(testDir)("--exact");
6767

6868
expect(await fs.readJSON(path.join(testDir, "lerna.json"))).toMatchObject({
69+
$schema: "node_modules/lerna/schemas/lerna-schema.json",
6970
command: {
7071
init: {
7172
exact: true,
@@ -91,6 +92,7 @@ describe("InitCommand", () => {
9192
]);
9293

9394
expect(lernaJson).toMatchObject({
95+
$schema: "node_modules/lerna/schemas/lerna-schema.json",
9496
packages: ["packages/*"],
9597
version: "0.0.0",
9698
});
@@ -190,6 +192,7 @@ describe("InitCommand", () => {
190192
await lernaInit(testDir)();
191193

192194
expect(await fs.readJSON(lernaJsonPath)).toEqual({
195+
$schema: "node_modules/lerna/schemas/lerna-schema.json",
193196
packages: ["packages/*"],
194197
useNx: false,
195198
version: "1.2.3",
@@ -223,6 +226,7 @@ describe("InitCommand", () => {
223226
hoist: true,
224227
},
225228
},
229+
$schema: "node_modules/lerna/schemas/lerna-schema.json",
226230
version: "1.2.3",
227231
});
228232
await fs.outputJSON(pkgJsonPath, {
@@ -242,6 +246,7 @@ describe("InitCommand", () => {
242246
exact: true,
243247
},
244248
},
249+
$schema: "node_modules/lerna/schemas/lerna-schema.json",
245250
packages: ["packages/*"],
246251
useNx: false,
247252
version: "1.2.3",

‎commands/init/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class InitCommand extends Command {
128128
}
129129

130130
Object.assign(config, {
131+
$schema: "node_modules/lerna/schemas/lerna-schema.json",
131132
packages: this.project.packageConfigs,
132133
useNx: false,
133134
version,

‎core/lerna/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"files": [
2020
"index.js",
21-
"cli.js"
21+
"cli.js",
22+
"schemas/lerna-schema.json"
2223
],
2324
"engines": {
2425
"node": "^14.15.0 || >=16.0.0"

‎core/lerna/schemas/lerna-schema.json

+1,833
Large diffs are not rendered by default.

‎e2e/tests/lerna-init/lerna-init.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe("lerna-init", () => {
2929

3030
expect(await fixture.readWorkspaceFile("lerna.json")).toMatchInlineSnapshot(`
3131
"{
32+
\\"$schema\\": \\"node_modules/lerna/schemas/lerna-schema.json\\",
3233
\\"packages\\": [
3334
\\"packages/*\\"
3435
],
@@ -65,6 +66,7 @@ describe("lerna-init", () => {
6566

6667
expect(await fixture.readWorkspaceFile("lerna.json")).toMatchInlineSnapshot(`
6768
"{
69+
\\"$schema\\": \\"node_modules/lerna/schemas/lerna-schema.json\\",
6870
\\"packages\\": [
6971
\\"packages/*\\"
7072
],
@@ -107,6 +109,7 @@ describe("lerna-init", () => {
107109
\\"exact\\": true
108110
}
109111
},
112+
\\"$schema\\": \\"node_modules/lerna/schemas/lerna-schema.json\\",
110113
\\"packages\\": [
111114
\\"packages/*\\"
112115
],
@@ -149,6 +152,7 @@ describe("lerna-init", () => {
149152
\\"exact\\": true
150153
}
151154
},
155+
\\"$schema\\": \\"node_modules/lerna/schemas/lerna-schema.json\\",
152156
\\"packages\\": [
153157
\\"packages/*\\"
154158
],

‎integration/lerna-init.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe("lerna init", () => {
3737
`);
3838
expect(lernaJson).toMatchInlineSnapshot(`
3939
Object {
40+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
4041
"packages": Array [
4142
"packages/*",
4243
],
@@ -71,6 +72,7 @@ describe("lerna init", () => {
7172
`);
7273
expect(lernaJson).toMatchInlineSnapshot(`
7374
Object {
75+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
7476
"command": Object {
7577
"bootstrap": Object {
7678
"hoist": true,

‎lerna.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "core/lerna/schemas/lerna-schema.json",
23
"command": {
34
"create": {
45
"homepage": "https://github.com/lerna/lerna",

0 commit comments

Comments
 (0)
Please sign in to comment.