Skip to content

Commit

Permalink
use existing api
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 7, 2024
1 parent 8e8d406 commit e1fe413
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 152 deletions.
3 changes: 2 additions & 1 deletion private/smithy-rpcv2-cbor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
"prepack": "yarn run clean && yarn run build"
"prepack": "yarn run clean && yarn run build",
"merged": "echo \"this is merged from user configuration.\""
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import software.amazon.smithy.codegen.core.SymbolDependency;
import software.amazon.smithy.model.node.Node;
import software.amazon.smithy.model.node.ObjectNode;
import software.amazon.smithy.typescript.codegen.util.MergeJsonNodes;
import software.amazon.smithy.utils.IoUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

Expand All @@ -44,11 +43,19 @@ static void writePackageJson(
) {
// Write the package.json file.
InputStream resource = PackageJsonGenerator.class.getResourceAsStream("base-package.json");
ObjectNode node = MergeJsonNodes.mergeWithScripts(
Node.parse(IoUtils.toUtf8String(resource))
.expectObjectNode(),
settings.getPackageJson()
);

ObjectNode userSuppliedPackageJson = settings.getPackageJson();
ObjectNode defaultPackageJson = Node.parse(IoUtils.toUtf8String(resource))
.expectObjectNode();

ObjectNode mergedScripts = defaultPackageJson.expectObjectMember("scripts")
.merge(
userSuppliedPackageJson.getObjectMember("scripts")
.orElse(ObjectNode.builder().build())
);

ObjectNode node = defaultPackageJson.merge(userSuppliedPackageJson)
.withMember("scripts", mergedScripts);

// Merge TypeScript dependencies into the package.json file.
for (Map.Entry<String, Map<String, SymbolDependency>> depEntry : dependencies.entrySet()) {
Expand Down

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions smithy-typescript-protocol-test-codegen/smithy-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"name": "Smithy team",
"url": "https://smithy.io/"
},
"scripts": {
"merged": "echo \"this is merged from user configuration.\""
},
"license": "Apache-2.0"
},
"private": true,
Expand Down

0 comments on commit e1fe413

Please sign in to comment.