Skip to content

Commit

Permalink
Merge pull request #72 from laxmanpokhrel/fix/individual-export-decle…
Browse files Browse the repository at this point in the history
…ration

fix: project type module
  • Loading branch information
laxmanpokhrel authored Feb 26, 2024
2 parents baeee38 + b0f5478 commit bb3a139
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 27 deletions.
39 changes: 27 additions & 12 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ echo "=========================================================="

# Declerations
RELEASE_CONFIG_FILE=null
RELEASE_TYPE=null
VERSION_UPGRADE_TYPE=null
RELEASE_TYPE=''
TAG=null

PACKAGEJSON=$(cat package.json)
Expand All @@ -30,15 +31,27 @@ fi
# Check if release config file has `versionUpgradeType`
echo "- reading 'versionUpgradeType'"
if [ "$(echo "$RELEASE_CONFIG_FILE" | jq -r ".versionUpgradeType")" != "null" ]; then
RELEASE_TYPE=$(echo "$RELEASE_CONFIG_FILE" | jq -r ".versionUpgradeType")
echo "- 'versionUpgradeType': $RELEASE_TYPE"
VERSION_UPGRADE_TYPE=$(echo "$RELEASE_CONFIG_FILE" | jq -r ".versionUpgradeType")
echo "- 'versionUpgradeType': $VERSION_UPGRADE_TYPE"
else
RELEASE_TYPE=null
VERSION_UPGRADE_TYPE=null
echo "- no 'versionUpgradeType' provided"
echo "- abort"
exit 1
fi

# Check if release config file has `releaseType`
echo "- reading 'releaseType'"
if [ "$(echo "$RELEASE_CONFIG_FILE" | jq -r ".releaseType")" != "null" ]; then
RELEASE_TYPE=$(echo "$RELEASE_CONFIG_FILE" | jq -r ".releaseType")
echo "- 'releaseType': $RELEASE_TYPE"
else
RELEASE_TYPE=''
echo "- no 'releaseType' provided"
# echo "- abort"
# exit 1
fi

# Check if npm view command succeeded or failed
echo "- reading package version from npm"
PACKAGE_NPM_VERSION=$(npm view $PACKAGE_NAME version 2>/dev/null)
Expand All @@ -54,7 +67,7 @@ else
FINAL_RELEASE_VERSION=$PACKAGE_VERSION
fi

# Function to update version based on RELEASE_TYPE
# Function to update version based on VERSION_UPGRADE_TYPE
update_version() {
local current_version=$1
local release_type=$2
Expand Down Expand Up @@ -84,14 +97,14 @@ update_version() {
if [ "$PACKAGE_NPM_VERSION" == "null" ]; then
FINAL_RELEASE_VERSION=$PACKAGE_VERSION
else
case $RELEASE_TYPE in
case $VERSION_UPGRADE_TYPE in
"major" | "minor" | "patch")
echo "- analysing version"
FINAL_RELEASE_VERSION=$(update_version "$PACKAGE_NPM_VERSION" "$RELEASE_TYPE") TAG=$FINAL_RELEASE_VERSION
FINAL_RELEASE_VERSION=$(update_version "$PACKAGE_NPM_VERSION" "$VERSION_UPGRADE_TYPE") TAG=$FINAL_RELEASE_VERSION
echo "- analysed deployable version $FINAL_RELEASE_VERSION"
;;
*)
echo "- invalid release type: $RELEASE_TYPE"
echo "- invalid release type: $VERSION_UPGRADE_TYPE"
;;
esac
fi
Expand All @@ -108,7 +121,7 @@ fi

# Check if release notes are available
echo "- reading release notes"
RELEASE_NOTES=$(cat .release/release-notes.md)
RELEASE_NOTES=$(cat .release/release-notes.txt)

if [ $? != 0 ]; then
echo "- release notes not provided"
Expand All @@ -121,12 +134,14 @@ echo "- RELEASE_NOTES: $RELEASE_NOTES"
echo "- PACKAGE_NAME: $PACKAGE_NAME"
echo "- PACKAGE_VERSION: $PACKAGE_VERSION"
echo "- FINAL_RELEASE_VERSION: $FINAL_RELEASE_VERSION"
echo "- RELEASE_TYPE:$RELEASE_TYPE"
echo "- TAG:$TAG"
echo "- VERSION_UPGRADE_TYPE: $VERSION_UPGRADE_TYPE"
echo "- TAG: $TAG"
echo "- RELEASE_TYPE: $RELEASE_TYPE"

# Set output
echo "tag=$(echo $TAG)" >>$GITHUB_OUTPUT
echo "release-notes=$(echo $RELEASE_NOTES)" >>$GITHUB_OUTPUT
echo "final-release-version=$(echo $FINAL_RELEASE_VERSION)" >>$GITHUB_OUTPUT
echo "release-type=$(echo $RELEASE_TYPE)" >>$GITHUB_OUTPUT
echo "release-type=$(echo $VERSION_UPGRADE_TYPE)" >>$GITHUB_OUTPUT
echo "package-version=$(echo $PACKAGE_VERSION)" >>$GITHUB_OUTPUT
echo "release-type=$(echo $RELEASE_TYPE)" >>$GITHUB_OUTPUT
10 changes: 6 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Deploy and Release
on:
workflow_dispatch:
push:
branches:
- main
Expand Down Expand Up @@ -59,11 +60,10 @@ jobs:
echo "package-version: ${{steps.read-release-props.outputs.package-version}}"
echo "release-type: ${{steps.read-release-props.outputs.release-type}}"
echo "final-release-version: ${{steps.read-release-props.outputs.final-release-version}}"
echo "final-release-version: ${{steps.read-release-props.outputs.final-release-version}}"
echo "release-type: ${{steps.read-release-props.outputs.release-type}}"
echo "isPrerelease: ${{steps.read-release-props.outputs.release-type}} == '--prerelease'"
- name: Checkout to new branch and update package json with new version
# if: steps.read-release-props.outcome.package-version != steps.read-release-props.outputs.final-release-version
# continue-on-error: true
id: branch-checkout-details
run: |
# Read current branch
Expand Down Expand Up @@ -107,9 +107,11 @@ jobs:
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="$title" \
--notes="${{ steps.read-release-props.outputs.release-notes }}"
--notes="${{ steps.read-release-props.outputs.release-notes }}" \
${{steps.read-release-props.outputs.release-type}}
- name: Push and raise a PR
if: ${{steps.read-release-props.outputs.release-type != '--prerelease'}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ yarn-error.log*

.vscode/*
test.ts
lib
lib/
@types/
3 changes: 2 additions & 1 deletion .release/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"versionUpgradeType": "patch"
"versionUpgradeType": "patch",
"releaseType": "--prerelease"
}
2 changes: 0 additions & 2 deletions .release/release-notes.md

This file was deleted.

1 change: 1 addition & 0 deletions .release/release-notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## This release for testing subpath modules and their declerations
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"type": "git",
"url": "https://github.com/laxmanpokhrel/xmanscript-utils.git"
},
"type": "module",
"exports": {
"./abbreviateCurrencyValue": "./lib/abbreviateCurrencyValue",
"./areObjectsEqual": "./lib/areObjectsEqual",
Expand All @@ -19,8 +20,8 @@
"./distributePercentageEquallyWithRemainder": "./lib/distributePercentageEquallyWithRemainder",
"./formatNumberToCommaString": "./lib/formatNumberToCommaString",
"./getDifferenceObject": {
"types": "./dist/getDifferenceObject/index.d.ts",
"default": "./dist/getDifferenceObject/index.js"
"types": "./lib/getDifferenceObject/index.d.ts",
"default": "./lib/getDifferenceObject/index.js"
},
"./getFileExtension": "./lib/getFileExtension",
"./getMinMax": "./lib/getMinMax",
Expand All @@ -34,15 +35,15 @@
"./partitionObjectsByKey": "./lib/partitionObjectsByKey",
"./removeObjectFromArray": "./lib/removeObjectFromArray",
"./scrollToComponent": {
"types": "./dist/scrollToComponent/index.d.ts",
"default": "./dist/scrollToComponent/index.js"
"types":"./lib/scrollToComponent/index.d.ts",
"default": "./lib/scrollToComponent/index.js"
},
"./setKeysToValueInObjects": "./lib/setKeysToValueInObjects",
"./setValueOfKeyForMatchingValuesOfAKey": "./lib/setValueOfKeyForMatchingValuesOfAKey",
"./splitArrayIntoChunks": "./lib/splitArrayIntoChunks",
"./strictIntersectObjects": {
"types": "./dist/strictIntersectObjects/index.d.ts",
"default": "./dist/strictIntersectObjects/index.js"
"types": "./lib/strictIntersectObjects/index.d.ts",
"default": "./lib/strictIntersectObjects/index.js"
},
"./toggleObjectInArray": "./lib/toggleObjectInArray",
"./uniqueValuesOfKey": "./lib/uniqueValuesOfKey",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": false,
"moduleResolution": "Bundler"
// "declarationDir": "./@types"

},
"exclude": ["node_modules"],
"include": [".eslintrc.js", "src", "src/**/*.ts"]
Expand Down

0 comments on commit bb3a139

Please sign in to comment.