projen: Using `--from` w/ file or remote repository format fails when the source descends from PythonProject.
Assuming we have a simple project defined locally as follows (that descends from JSIIProject):
in templates/src/index.ts:
export class MyProject extends python.PythonProject {
constructor(options: python.PythonProjectOptions) {
super(options);
}
}
After building the project and compiling the JSII, when I try to use the template from another project directory, such as new_project
:
projen new --from file:../templates
I get the following error:
Error: Cannot find module 'templates/.jsii'
If you try the same using a remote repository, you will get:
Error: Cannot find module 'git/.jsii'
I looked into the code, and it looks like this is erroring at this point:
Installing from an NPM or private NPM server still works.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (6 by maintainers)
@orlandronen1 thanks for the tip, renaming the tarball did work
works:
npx projen new zaiPython --packageManager npm --from /home/zmully/gitwork/python-test-2/dist/js/python-test-2.tgz
does not work:
npx projen new zaiPython --packageManager npm --from python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2.tgz
npx projen new zaiPython --packageManager npm --from "python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2.tgz"
npx projen new zaiPython --packageManager npm --from "python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2@0.0.0.jsii.tgz"
And like you said, pulling from a registry solves many of these issues, but it’d be great if that friction could be removed to speed up development.
@mrgrain still not working with the package name addition:
Ah yes, so projen parses the this “spec” differently than npm. While npm is clever enough to figure out that this is a path, we don’t do this check in projen:
https://github.dev/projen/projen/blob/274682b35bd13ccacfb8444270e85c891838ea19/src/cli/cmds/new.ts#L283-L285 The whole path is just added as dependency, which later on will be split at the
@
and that’s how it ends up inpackage.json
.I think instead of blindly adding the spec string as dev dependency, we need to check against the
moduleName
that’s returned from the install helper. Or even discardspec
and use whatever name/version npm comes back with.In the meantime, I also noticed this comment: https://github.dev/projen/projen/blob/274682b35bd13ccacfb8444270e85c891838ea19/src/cli/util.ts#L6-L11
And for me
projen new --from @mb/cdk-project-backbone@/Users/tymoteuszgach/git/tyga/cdk-project-backbone/dist/js/cdk-project-backbone@0.0.0.jsii.tgz
works!