-
Notifications
You must be signed in to change notification settings - Fork 149
@W-21182296 Make 'webapplication.json' optional + validation #1682
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
base: main
Are you sure you want to change the base?
@W-21182296 Make 'webapplication.json' optional + validation #1682
Conversation
b1382cc to
c11198b
Compare
| } | ||
|
|
||
| if (!config.outputDir || typeof config.outputDir !== 'string') { | ||
| this.expectedSourceError(descriptorPath); |
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.
should these output the props that are missing?
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.
Nope. Pushed the fix that will output all missing props.
k-j-kim
left a comment
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.
other than a more specific error message for missing props, lgtm!
| } | ||
| if (this.tree.readFileSync(indexPath).length === 0) { | ||
| this.expectedSourceError(indexPath); | ||
| } |
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 errors messages (below) for validating the webapplication.json contents are really clear. These errors here too feel vague. How about something like: If a webapplication.json file does not exist, you are require to include a 'dist/index.tml' file. This will be the entry point for your webapplication
| } catch (e) { | ||
| const detail = e instanceof Error ? e.message : String(e); | ||
| throw new SfError(`Invalid JSON in webapplication.json: ${detail}`, 'InvalidJsonError'); | ||
| } |
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.
General question for the webapplication.json file and its contents: Do you have any public docs you could link to for the correct structure of this config file? This could help users validate all potential errors in a single pass rather than fixing one, getting an error, fixing one, etc.
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.
Not yet. We’re still working on finalizing its structure, but for now we’ve defined the required properties.
| ); | ||
| } | ||
|
|
||
| const fallbackPath = join(outputDirPath, config.routing.fallback.replace(/^\//, '')); |
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.
Should this replace use path.sep instead?
|
|
||
| const fallbackPath = join(outputDirPath, config.routing.fallback.replace(/^\//, '')); | ||
| if (!this.tree.exists(fallbackPath)) { | ||
| this.expectedSourceError(fallbackPath); |
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.
This also feels too vague. "The filepath defined in the webapplication.json -> routing.fallback was not found. Ensure this file exists at the location defined."
| if (Array.isArray(config.routing.rewrites)) { | ||
| for (const { rewrite } of config.routing.rewrites) { | ||
| if (rewrite) { | ||
| const rewritePath = join(outputDirPath, rewrite.replace(/^\//, '')); |
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.
path.sep instead of ^\/?
- webapplication.json optional: when absent or force-ignored, require non-empty dist/index.html - Validate required fields (outputDir, routing, trailingSlash, fallback) with clear error messages - Validate fallback and rewrite targets exist on disk - Precise error messages for dist fallback (missing folder, missing file, empty file) - Use path.sep for cross-platform path handling Co-authored-by: Cursor <cursoragent@cursor.com>
2b12667 to
68a8f79
Compare
…JSON test Co-authored-by: Cursor <cursoragent@cursor.com>
What does this PR do?
Removed the requirement that webapplication.json must exist. If it exists, we check that the files it references are present. If it's missing or force-ignored, we require a non-empty dist/index.html instead. This supports apps without a JSON config and allows force-ignoring the descriptor.
What issues does this PR fix or reference?
N/A
#, @@
Functionality Before
webapplication.json was required, and at least one content file (besides the metadata XML) was required.
Functionality After
webapplication.json is optional; if present, we validate its fields and check that referenced files exist; if missing or force-ignored, we require a non-empty dist/index.html instead.