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

angular build adatper draft #139

Merged
merged 14 commits into from
Feb 7, 2024
Merged

angular build adatper draft #139

merged 14 commits into from
Feb 7, 2024

Conversation

sjjj986
Copy link
Collaborator

@sjjj986 sjjj986 commented Jan 29, 2024

angular build adapter script

output directory structure & bundle.yaml file after running adapter:
Screenshot 2024-01-29 at 5 00 46 PM

first draft of angular build adapter code
@sjjj986 sjjj986 requested a review from jamesdaniels January 29, 2024 22:01
@sjjj986 sjjj986 requested a review from Yuangwang as a code owner January 29, 2024 22:01
@sjjj986 sjjj986 self-assigned this Jan 29, 2024
@sjjj986 sjjj986 marked this pull request as draft January 29, 2024 22:22
@sjjj986 sjjj986 marked this pull request as ready for review January 29, 2024 22:39
packages/@apphosting/adapter-angular/src/bin/build.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/bin/build.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/bin/build.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/bin/build.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/utils.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Yuangwang Yuangwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/@apphosting/adapter-angular/src/bin/build.ts Outdated Show resolved Hide resolved
// TODO do all the things
console.log({ config });
const outputBundleOptions = populateOutputBundleOptions();
await build().catch(() => process.exit(1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the intention of catching and then doing process.exit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'spawn' event will fire regardless of whether an error occurs within the spawned process. So in case reject(), we can catch and exit with 1

refactor to move helpers to utils.ts, and add interface.ts
enable angular build logs to obtain the manifest, which contains outputpaths and a build summary.
@sjjj986 sjjj986 requested a review from leoortizz as a code owner February 1, 2024 20:32
packages/@apphosting/adapter-angular/src/bin/build.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/utils.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/utils.ts Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
@sjjj986 sjjj986 marked this pull request as draft February 1, 2024 21:38
Remove manually loading angular application builder options & normalizing options

Use build manifest from stdout, verify its format with zod, and then extract the output paths.

Errors and warnings from the manifest will be logged.
@sjjj986 sjjj986 marked this pull request as ready for review February 5, 2024 07:29
@sjjj986
Copy link
Collaborator Author

sjjj986 commented Feb 5, 2024

Removed manually loading angular application builder options & normalizing options
Use build manifest from stdout, verify its format with zod, and then extract the output paths.
Errors and warnings from the manifest will be logged.

@@ -13,6 +13,7 @@ module.exports = {
],
rules: {
"jsdoc/newline-after-description": "off",
"@typescript-eslint/no-explicit-any": "off", // TODO(sijin): remove later
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this turned off?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to do the zod custom url type I have to use type any, couldn't figure out how to make it work without turning off "no-explicit-any"

Copy link
Collaborator

@jamesdaniels jamesdaniels Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a eslint-disable-next-line comment above the line in question, rather than disable the rule

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw unknown is an alternative to any that doesn't require changing the ESLint rules

packages/@apphosting/adapter-angular/src/interface.ts Outdated Show resolved Hide resolved
packages/@apphosting/adapter-angular/src/utils.ts Outdated Show resolved Hide resolved
manifest.errors.forEach((error) => {
logger.error(error);
});
reject();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be an error inside of reject(). This will help for debugging in the future go/tsjs-style#only-throw-errors

if (manifest["outputPaths"]) {
outputPathOptions = populateOutputBundleOptions(manifest["outputPaths"]);
} else {
throw new Error("Could not find output paths from the build manifest.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case where this error is thrown and then caught in line 108, what happens to outputPathOptions? Is it {} still? Does that work still?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outputpaths should always be there, so I fixed this part. This manifest should be validated by zod and outputPathOptions should not be empty

@@ -14,6 +14,7 @@
"packages/**/*"
],
"devDependencies": {
"@angular-devkit/build-angular": "^17.1.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this to the package.json in packages/@apphosting/adapter-angular

@@ -25,6 +26,7 @@
"mocha": "^10.2.0",
"prettier": "^3.0.3",
"ts-mocha": "^10.0.0",
"typescript": "^5.2.0"
"typescript": "^5.2.0",
"zod": "^3.22.4"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also move to package.json in packages/@apphosting/adapter-angular

}
});
} else {
throw new Error("Unable to locate build manifest with output paths.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not throw here, ignore since the SSG / other build scripts might be emitting to stdout

shell: true,
stdio: ["inherit", "pipe", "pipe"],
});
let outputPathOptions = {} as OutputPathOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead, let's make this let outputPathOptions: OutputPathOptions | undefined; and on exit, throw is outputPathOptions is still undefined

Copy link
Collaborator

@jamesdaniels jamesdaniels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some nits, if you have time feel free to address otherwise we can circle back

@Yuangwang Yuangwang merged commit cbdb6cb into main Feb 7, 2024
10 checks passed
@jamesdaniels jamesdaniels deleted the angulalr-adapter-draft branch February 7, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants