Skip to content

Commit abcb200

Browse files
AdamSzAppleGitHub Enterprise
authored andcommitted
Use tar instead of npm for packaging. (apple#52)
1 parent 6590c65 commit abcb200

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/python/upi_unity_native_plugin_manager.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env python3
22
# Requirements: python3
33

4-
import os, shutil
4+
import os, shutil, json
55

66
import scripts.python.upi_utility as utility
77
import scripts.python.upi_toolchain as toolchain
@@ -392,9 +392,9 @@ def ValidateProjectVersions(self):
392392
else:
393393
CTX.printer.ErrorMessage("No Unity installations are being tracked. Please check your Unity installation root path or install the Unity Editor.")
394394

395-
# Packs plug-ins with npm and moves the resulting package to the currently configured build output folder.
395+
# Packs plug-ins with tar and moves the resulting package to the currently configured build output folder.
396396
def GeneratePlugInPackages(self) -> None:
397-
# Cache to return; npm should be invoked from the folder containing the associated package.json
397+
# Cache to return; tar should be invoked from the folder containing the associated package.json
398398
working_dir = os.getcwd()
399399
for plugin_id, native_plugin in self.native_unity_plugin_table.items():
400400
CTX.printer.StatusMessageWithContext("Packing plug-in: ", f"{plugin_id}", "\n")
@@ -424,8 +424,15 @@ def GeneratePlugInPackages(self) -> None:
424424
utility.RunCommand(["mv", curr_demo_path, dest_demo_path])
425425
utility.RunCommand(["mv", curr_demo_meta_path, dest_demo_meta_path])
426426

427-
pack_command = ["npm", "pack", f"{target_package_json_path.parent}", "--pack-destination", f"{CTX.build_output_path}"]
428-
427+
# get the package name and version
428+
package_json_file = open(target_package_json_path)
429+
package_json_data = json.load(package_json_file)
430+
tgz_filename = f"{package_json_data['name']}" "-" f"{package_json_data['version']}" ".tgz"
431+
package_json_file.close()
432+
433+
# using tar:
434+
pack_command = ["tar", "--auto-compress", "--create", "--file", f"{CTX.build_output_path.joinpath(tgz_filename)}", "--directory", f"{target_package_json_path.parent}", "-s", "/./package/", "." ]
435+
429436
CTX.printer.MessageWithContext("Project package.json path: ", f"{target_package_json_path}", CTX.printer.Indent(1))
430437
CTX.printer.MessageWithContext("Pack command: ", f"{(' '.join(pack_command))}", CTX.printer.Indent(1))
431438

0 commit comments

Comments
 (0)