Skip to content
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

format: Sort package.json #1016

Merged
merged 3 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hot-kiwis-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'skuba': minor
---

format: Sort package.json
6 changes: 3 additions & 3 deletions integration/base/ok/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"dependencies": {},
"devDependencies": {},
"license": "UNLICENSED",
"private": true,
"license": "UNLICENSED",
"sideEffects": false,
"dependencies": {},
"devDependencies": {},
"skuba": {
"entryPoint": null,
"template": null,
Expand Down
6 changes: 3 additions & 3 deletions integration/base/unfixable/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"dependencies": {},
"devDependencies": {},
"license": "UNLICENSED",
"private": true,
"license": "UNLICENSED",
"sideEffects": false,
"dependencies": {},
"devDependencies": {},
"skuba": {
"entryPoint": null,
"template": null,
Expand Down
134 changes: 67 additions & 67 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,71 @@
{
"name": "skuba",
"version": "4.4.1",
"private": false,
"description": "SEEK development toolkit for backend applications and packages",
"homepage": "https://github.com/seek-oss/skuba#readme",
"bugs": {
"url": "https://github.com/seek-oss/skuba/issues"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/seek-oss/skuba.git"
},
"license": "MIT",
"sideEffects": false,
"main": "lib/index.js",
"types": "./lib/index.d.ts",
"bin": {
"skuba": "lib/skuba.js"
},
"bugs": {
"url": "https://github.com/seek-oss/skuba/issues"
"files": [
"config/**/*",
"jest/**/*",
"lib*/**/*.d.ts",
"lib*/**/*.js",
"lib*/**/*.js.map",
"template/**/*",
"jest-preset.js"
],
"scripts": {
"build": "scripts/build.sh",
"deploy": "scripts/deploy.sh",
"format": "yarn skuba format",
"lint": "yarn skuba lint && yarn lint:md",
"lint:md": "remark --frail --quiet .",
"release": "yarn build && changeset publish",
"skuba": "yarn build && node lib/skuba",
"stage": "changeset version && yarn format",
"test": "yarn skuba test",
"test:ci": "yarn skuba test --config jest.config.int.ts --runInBand",
"test:int": "yarn skuba test --config jest.config.int.ts --runInBand",
"test:template": "scripts/test-template.sh",
"test:watch": "yarn skuba test --config jest.config.int.ts --runInBand --watch"
},
"remarkConfig": {
"plugins": [
"remark-preset-lint-recommended",
[
"remark-lint-list-item-indent",
false
],
[
"remark-lint-no-shortcut-reference-link",
false
],
[
"remark-lint-no-undefined-references",
{
"allow": [
" ",
"x"
]
}
]
]
},
"resolutions": {
"**/@types/node": ">=14.18"
},
"dependencies": {
"@esbuild-plugins/tsconfig-paths": "^0.0.4",
Expand Down Expand Up @@ -56,7 +118,6 @@
"typescript": "~4.8.2",
"validate-npm-package-name": "^5.0.0"
},
"description": "SEEK development toolkit for backend applications and packages",
"devDependencies": {
"@changesets/cli": "2.25.0",
"@changesets/get-github-info": "0.5.1",
Expand All @@ -83,22 +144,6 @@
"supertest": "6.3.0",
"type-fest": "2.19.0"
},
"engines": {
"node": ">=14.18"
},
"files": [
"config/**/*",
"jest/**/*",
"lib*/**/*.d.ts",
"lib*/**/*.js",
"lib*/**/*.js.map",
"template/**/*",
"jest-preset.js"
],
"homepage": "https://github.com/seek-oss/skuba#readme",
"license": "MIT",
"main": "lib/index.js",
"name": "skuba",
"peerDependencies": {
"skuba-dive": "1 || 2"
},
Expand All @@ -107,59 +152,14 @@
"optional": true
}
},
"private": false,
"remarkConfig": {
"plugins": [
"remark-preset-lint-recommended",
[
"remark-lint-list-item-indent",
false
],
[
"remark-lint-no-shortcut-reference-link",
false
],
[
"remark-lint-no-undefined-references",
{
"allow": [
" ",
"x"
]
}
]
]
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/seek-oss/skuba.git"
},
"resolutions": {
"**/@types/node": ">=14.18"
},
"scripts": {
"build": "scripts/build.sh",
"deploy": "scripts/deploy.sh",
"format": "yarn skuba format",
"lint": "yarn skuba lint && yarn lint:md",
"lint:md": "remark --frail --quiet .",
"release": "yarn build && changeset publish",
"stage": "changeset version && yarn format",
"skuba": "yarn build && node lib/skuba",
"test": "yarn skuba test",
"test:ci": "yarn skuba test --config jest.config.int.ts --runInBand",
"test:int": "yarn skuba test --config jest.config.int.ts --runInBand",
"test:template": "scripts/test-template.sh",
"test:watch": "yarn skuba test --config jest.config.int.ts --runInBand --watch"
"engines": {
"node": ">=14.18"
},
"sideEffects": false,
"skuba": {
"build": "esbuild",
"entryPoint": "src/index.ts",
"template": null,
"type": "package",
"version": "4.0.0"
},
"types": "./lib/index.d.ts",
"version": "4.4.1"
}
}
3 changes: 2 additions & 1 deletion src/cli/__snapshots__/format.int.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Processed 2 files in <random>s.

Prettier
Processed 6 files in <random>s.
Formatted 3 files:
Formatted 4 files:
b.md
c.json
d.js
package.json
"
`;

Expand Down
13 changes: 13 additions & 0 deletions src/cli/adapter/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { crawlDirectory } from '../../utils/dir';
import type { Logger } from '../../utils/logging';
import { pluralise } from '../../utils/logging';
import { getConsumerManifest } from '../../utils/manifest';
import { formatPackage, parsePackage } from '../configure/processing/package';

let languages: SupportLanguage[] | undefined;

Expand Down Expand Up @@ -87,6 +88,18 @@ const formatOrLintFile = (
return;
}

// Perform additional formatting (i.e. sorting) on a `package.json` manifest.
try {
if (path.basename(filepath) === 'package.json') {
const packageJson = parsePackage(formatted);
if (packageJson) {
formatted = formatPackage(packageJson);
}
}
} catch {
// Our additional formatting is strictly optional; don't throw if it fails.
}

if (formatted === data) {
return;
}
Expand Down
24 changes: 12 additions & 12 deletions template/express-rest-api/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "skuba build",
"format": "skuba format",
"lint": "skuba lint",
"start": "skuba start --port <%- port %>",
"start:debug": "yarn start --inspect-brk",
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
},
"dependencies": {
"@seek/logger": "^5.0.1",
"express": "^4.17.1",
Expand All @@ -14,17 +26,5 @@
},
"engines": {
"node": ">=16"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"build": "skuba build",
"format": "skuba format",
"lint": "skuba lint",
"start": "skuba start --port <%- port %>",
"start:debug": "yarn start --inspect-brk",
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
}
}
22 changes: 11 additions & 11 deletions template/greeter/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"dependencies": {
"skuba-dive": "^2.0.0"
},
"devDependencies": {
"@types/node": "16.11.64",
"skuba": "*"
},
"engines": {
"node": ">=16"
},
"license": "UNLICENSED",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "skuba build",
"format": "skuba format",
Expand All @@ -20,5 +10,15 @@
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
},
"dependencies": {
"skuba-dive": "^2.0.0"
},
"devDependencies": {
"@types/node": "16.11.64",
"skuba": "*"
},
"engines": {
"node": ">=16"
}
}
24 changes: 12 additions & 12 deletions template/koa-rest-api/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "skuba build",
"format": "skuba format",
"lint": "skuba lint",
"start": "skuba start --port <%- port %>",
"start:debug": "yarn start --inspect-brk",
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
},
"dependencies": {
"@koa/router": "^12.0.0",
"@opentelemetry/api": "^1.1.0",
Expand Down Expand Up @@ -31,17 +43,5 @@
},
"engines": {
"node": ">=16"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"build": "skuba build",
"format": "skuba format",
"lint": "skuba lint",
"start": "skuba start --port <%- port %>",
"start:debug": "yarn start --inspect-brk",
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
}
}
24 changes: 12 additions & 12 deletions template/lambda-sqs-worker-cdk/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "skuba build",
"deploy": "cdk deploy appStack --require-approval never --context stage=${ENVIRONMENT}",
"format": "skuba format",
"lint": "skuba lint",
"package": "yarn install --ignore-optional --ignore-scripts --modules-folder ./lib/node_modules --non-interactive --offline --production",
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
},
"dependencies": {
"@seek/logger": "^5.0.1",
"zod": "^3.19.1"
Expand All @@ -14,17 +26,5 @@
},
"engines": {
"node": ">=16"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"build": "skuba build",
"deploy": "cdk deploy appStack --require-approval never --context stage=${ENVIRONMENT}",
"format": "skuba format",
"lint": "skuba lint",
"package": "yarn install --ignore-optional --ignore-scripts --modules-folder ./lib/node_modules --non-interactive --offline --production",
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch"
}
}
Loading