-
Notifications
You must be signed in to change notification settings - Fork 64
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
fix: compile nmp library as 'commonjs' module #1666
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,12 +53,49 @@ EOF | |
export OPENAPI_GENERATOR_COMMIT="v6.3.0" | ||
bash $WORK_DIR/gen/openapi/typescript.sh $WORK_DIR/typescript-models $WORK_DIR/config.sh | ||
|
||
apply_sed 's/\"name\": \".*\"/"name": "@devfile\/api"/g' $WORK_DIR/typescript-models/package.json | ||
apply_sed 's/\"description\": \".*\"/"description": "Typescript types for devfile api"/g' $WORK_DIR/typescript-models/package.json | ||
apply_sed 's/\"repository\": \".*\"/"repository": "devfile\/api"/g' $WORK_DIR/typescript-models/package.json | ||
apply_sed 's/\"license\": \".*\"/"license": "Apache-2.0"/g' $WORK_DIR/typescript-models/package.json | ||
apply_sed 's/\"@types\/bluebird\": \".*\"/"@types\/bluebird": "3.5.21"/g' $WORK_DIR/typescript-models/package.json | ||
|
||
local workdir=$(pwd) | ||
cd "$WORK_DIR/typescript-models" | ||
|
||
###################################################################################################### | ||
echo "[INFO] preparing package.json" | ||
###################################################################################################### | ||
|
||
echo "$(jq '. += {"name": "@devfile/api"}' package.json)" > package.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the addition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we speak about the action that builds and then publishes the typescript models, it runs on ubuntu and there is a dedicated section to install node https://github.com/devfile/api/blob/main/.github/workflows/release-typescript-models.yaml#L48-L53. So no issues with it. If you want to build typescript models locally, you definitely need to have Btw, typescript models are generated in a separate container. Node is used then to build and publish the generated library. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vitaliy-guliy Sounds good 👍 |
||
echo "$(jq '. += {"description": "Typescript types for devfile api"}' package.json)" > package.json | ||
echo "$(jq '.repository += {"url": "https://github.com/devfile/api"}' package.json)" > package.json | ||
echo "$(jq '. += {"homepage": "https://github.com/devfile/api/blob/main/README.md"}' package.json)" > package.json | ||
echo "$(jq '. += {"license": "Apache-2.0"}' package.json)" > package.json | ||
|
||
echo "$(jq 'del(.main)' package.json)" > package.json | ||
echo "$(jq 'del(.type)' package.json)" > package.json | ||
echo "$(jq 'del(.module)' package.json)" > package.json | ||
echo "$(jq 'del(.exports)' package.json)" > package.json | ||
echo "$(jq 'del(.typings)' package.json)" > package.json | ||
|
||
echo "$(jq '. += {"main": "dist/index.js"}' package.json)" > package.json | ||
echo "$(jq '. += {"types": "dist/index.d.ts"}' package.json)" > package.json | ||
|
||
###################################################################################################### | ||
echo "[INFO] preparing tsconfig.json" | ||
###################################################################################################### | ||
|
||
# remove comments | ||
cp -f tsconfig.json tsconfig.json.copy | ||
node -p 'JSON.stringify(eval(`(${require("fs").readFileSync("tsconfig.json.copy", "utf-8").toString()})`))' | jq > tsconfig.json | ||
|
||
# remove unwanted properties | ||
echo "$(jq 'del(.compilerOptions.noUnusedLocals)' tsconfig.json)" > tsconfig.json | ||
echo "$(jq 'del(.compilerOptions.noUnusedParameters)' tsconfig.json)" > tsconfig.json | ||
echo "$(jq 'del(.compilerOptions.noImplicitReturns)' tsconfig.json)" > tsconfig.json | ||
echo "$(jq 'del(.compilerOptions.noFallthroughCasesInSwitch)' tsconfig.json)" > tsconfig.json | ||
|
||
# add module type | ||
echo "$(jq '.compilerOptions += {"module": "commonjs"}' tsconfig.json)" > tsconfig.json | ||
# add skipLibCheck | ||
echo "$(jq '.compilerOptions += {"skipLibCheck": true}' tsconfig.json)" > tsconfig.json | ||
|
||
cd $workdir | ||
|
||
echo "" > $WORK_DIR/typescript-models/.npmignore | ||
echo "[INFO] Generated typescript model which now is available in $WORK_DIR/typescript-models" | ||
} | ||
|
@@ -86,14 +123,6 @@ build_typescript_model() { | |
echo "[INFO] Done." | ||
} | ||
|
||
apply_sed(){ | ||
if [ "$(uname)" == "Darwin" ]; then | ||
sed -i '' "$@" | ||
else | ||
sed -i "$@" | ||
fi | ||
} | ||
|
||
generate_swagger_json | ||
k8s_client_gen | ||
generate_typescript_metadata | ||
|
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.
Do we know if it's okay to remove
?
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 could have deleted it by accident.
I will double check it.
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 recalled why did I remove it at all, there was no dependency on
bluebird
inpackage.json
.To check, go to https://www.npmjs.com/package/@devfile/api?activeTab=code and open existing
package.json