-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Feature/extensions sdk cli validate #24269
base: main
Are you sure you want to change the base?
Feature/extensions sdk cli validate #24269
Conversation
🦋 Changeset detectedLatest commit: 5ff39df The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Does not seem like we currently have tests for the cli commands. Might be worth adding if low complexity
Note that
|
I'll check this out tomorrow, but we may also want to flag a warning if an extension cannot be published to the marketplace because it is a bundle or API extension and not sandboxed. |
…dlz/directus into feature/extensions-sdk-cli-validate
I've added the functionality to give a warning, as well as a specific test for appearing in the marketplace |
…nse.ts Co-authored-by: Hannes Küttner <kuettner.hannes@gmail.com>
Co-authored-by: Hannes Küttner <kuettner.hannes@gmail.com>
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.
Added basic integration tests in 29a311f.
In order for them to pass, the following changes are necessary:
- in case of invalid checks, the process should exit with exit code 1
- check the license field in package.json instead of license file
- allow all readme file namings according to the official specs:
README & LICENSE can have any case and extension.
- the
directus-config
check is currently failing with initial extension state (which should of course be valid):reason: TypeError: string "interface" is not a function at Array.findIndex (<anonymous>) at Object.handler (file:///<...>/dist/cli/commands/validators/check-directus-config.js:68:76)
…from package.json & file, validate semver the same as marketplace frontend
…dlz/directus into feature/extensions-sdk-cli-validate
packages/extensions-sdk/src/cli/commands/validators/check-built-code.ts
Outdated
Show resolved
Hide resolved
packages/extensions-sdk/src/cli/commands/validators/check-license.ts
Outdated
Show resolved
Hide resolved
…nse.ts Co-authored-by: Hannes Küttner <kuettner.hannes@gmail.com>
const packageFile = await fse.readJson(packagePath); | ||
|
||
if (packageFile[EXTENSION_PKG_KEY]) { | ||
const { path } = packageFile[EXTENSION_PKG_KEY]; |
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.
The path
value could be an object that breaks subsequent checks.
path: { app: 'dist/app.js', api: 'dist/api.js' },
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.
I think I've solved this on L36-L52 now
const message = `No ${codePath} directory`; | ||
|
||
reports.push({ | ||
level: 'error', | ||
message: `${checkBuiltCode.name}: ${message}`, | ||
}); |
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.
Small nitpick and non-blocking but we do message
+ reports.push({...})
in quite a few places, might be worth to extract to a util?
Alternatively we can rework the validators to return back the level
& message
or throw an Error
that we then process in the main thread instead of passing around a mutable reports array. The name
can be extracted from the respective command.
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.
Looking good! Mostly small nitpick non-blocking comments
packages/extensions-sdk/src/cli/commands/validators/check-license.ts
Outdated
Show resolved
Hide resolved
packages/extensions-sdk/src/cli/commands/validators/check-readme.ts
Outdated
Show resolved
Hide resolved
packages/extensions-sdk/src/cli/commands/validators/check-readme.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
…me.ts Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
…me.ts Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
…nse.ts Co-authored-by: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
Scope
What's changed:
validate
command for theextensions-sdk
CLI/dist
directory, README, license field, and a validdirectus:extension
object within thepackage.json
Potential Risks / Drawbacks
Review Notes / Questions
Closes #DX-547