Skip to content

Commit

Permalink
Updates to packages unresolvable by no-extraneous-dependencies (#1997)
Browse files Browse the repository at this point in the history
* added main field to packages that lack it

* added changeset

* added custom script for verifying packages have main, added main to 9 packages

* updated error message for script to check for main field

* added changeset

* fixed private problem, changed file name

* added ignore for packages with violations, included in lint check

* Update scripts/check_package_json.ts

Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>

---------

Co-authored-by: Vieltojarvi <lvielto@amazon.com>
Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>
  • Loading branch information
3 people committed Sep 16, 2024
1 parent fe6c23d commit e648e8e
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .changeset/forty-buckets-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@aws-amplify/deployed-backend-client': patch
'@aws-amplify/backend-deployer': patch
'@aws-amplify/backend-function': patch
'@aws-amplify/schema-generator': patch
'@aws-amplify/backend-storage': patch
'@aws-amplify/model-generator': patch
'@aws-amplify/auth-construct': patch
'@aws-amplify/backend-secret': patch
'create-amplify': patch
'@aws-amplify/form-generator': patch
'@aws-amplify/client-config': patch
'@aws-amplify/backend-auth': patch
'@aws-amplify/backend-data': patch
'@aws-amplify/backend': patch
'@aws-amplify/sandbox': patch
'ampx': patch
'@aws-amplify/backend-cli': patch
---

added main field to package.json so these packages are resolvable
12 changes: 12 additions & 0 deletions .changeset/yellow-jokes-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@aws-amplify/deployed-backend-client': patch
'@aws-amplify/backend-deployer': patch
'@aws-amplify/schema-generator': patch
'@aws-amplify/model-generator': patch
'@aws-amplify/backend-secret': patch
'@aws-amplify/form-generator': patch
'@aws-amplify/client-config': patch
'@aws-amplify/sandbox': patch
---

added main field to packages known to lack one
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"diff:check": "tsx scripts/check_pr_size.ts",
"docs": "typedoc",
"e2e:cleanup-resources": "tsx scripts/cleanup_e2e_resources.ts",
"lint": "eslint --max-warnings 0 . && prettier --check .",
"lint": "eslint --max-warnings 0 . && tsx scripts/check_package_json.ts && prettier --check .",
"lint:fix": "eslint --cache --fix . && prettier --write .",
"live-dependency-health-checks": "npm run test:dir packages/integration-tests/lib/test-live-dependency-health-checks",
"new": "tsx scripts/copy_template.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/ampx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/auth-construct/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend-deployer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend-function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend-secret/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"types": "./lib/types/platform.d.ts"
}
},
"main": "lib/index.js",
"imports": {
"#package.json": "./package.json"
},
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amplify": "lib/ampx.js"
},
"type": "module",
"main": "lib/index.js",
"publishConfig": {
"access": "public"
},
Expand Down
1 change: 1 addition & 0 deletions packages/client-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"require": "./lib/paths/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/create-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "create-amplify",
"version": "1.0.5",
"type": "module",
"main": "lib/index.js",
"publishConfig": {
"access": "public"
},
Expand Down
1 change: 1 addition & 0 deletions packages/deployed-backend-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/form-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/model-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
1 change: 1 addition & 0 deletions packages/schema-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": "./lib/index.js"
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"update:api": "api-extractor run --local"
Expand Down
31 changes: 31 additions & 0 deletions scripts/check_package_json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { glob } from 'glob';
import { readPackageJson } from './components/package-json/package_json.js';

const packagePaths = await glob('./packages/*');

// Excluding packages that violate 'import/no-extraneous-dependencies' rule until they're fixed.
const tempExclude: string[] = [
'@aws-amplify/plugin-types',
'@aws-amplify/cli-core',
];
const errors: string[] = [];
for (const packagePath of packagePaths) {
const {
main,
name,
private: privatePackage,
} = await readPackageJson(packagePath);
if (privatePackage || tempExclude.includes(name)) {
continue;
}
if (!main) {
errors.push(
`Expected package ${name} to have field main, but main is missing.`
);
}
}
if (errors.length > 0) {
const errorMessagePrefix =
'Packages were found to be missing main fields.\nAdd main field to package.json of the following packages:';
throw new Error(`${errorMessagePrefix}\n ${errors.join('\n ')}`);
}

0 comments on commit e648e8e

Please sign in to comment.