From 769434703dc8a0f1d519377bae6bc4d41142d1f2 Mon Sep 17 00:00:00 2001 From: Emerson Hsieh Date: Thu, 13 Apr 2023 17:08:31 -0400 Subject: [PATCH 1/2] feat: allow directory names with files in deploy.json so files can be grouped into directories --- packages/cli/src/contracts/LibDeploy.ejs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/contracts/LibDeploy.ejs b/packages/cli/src/contracts/LibDeploy.ejs index 4d1ca0e23c..d747cd1eac 100644 --- a/packages/cli/src/contracts/LibDeploy.ejs +++ b/packages/cli/src/contracts/LibDeploy.ejs @@ -17,18 +17,21 @@ import { SystemStorage } from "solecs/SystemStorage.sol"; // Components (requires 'components=...' remapping in project's remappings.txt) <% components.forEach(component => { -%> -import { <%= component %>, ID as <%= component %>ID } from "components/<%- component %>.sol"; +<% const componentName = component.split("/").pop(); %> +import { <%= componentName %>, ID as <%= componentName %>ID } from "components/<%- component %>.sol"; <% }); -%> // Systems (requires 'systems=...' remapping in project's remappings.txt) <% systems.forEach(system => { -%> -import { <%= system.name %>, ID as <%= system.name %>ID } from "systems/<%- system.name %>.sol"; +<% const systemName=system.name.split("/").pop(); %> +import { <%= systemName %>, ID as <%= systemName %>ID } from "systems/<%- system.name %>.sol"; <% }); -%> <% if (initializers.length > 0) { -%> // Initializer libraries (requires 'libraries=...' remapping in project's remappings.txt) <% initializers.forEach((initializer) => { -%> -import { <%= initializer %> } from "libraries/<%- initializer %>.sol"; +<% const initializerName=initializer.name.split("/").pop(); %> +import { <%= initializerName %> } from "libraries/<%- initializer %>.sol"; <% }); -%> <% } -%> From 5760baf30c08c9cbba5e1f93598cff597f2a25db Mon Sep 17 00:00:00 2001 From: Emerson Hsieh Date: Thu, 13 Apr 2023 17:27:39 -0400 Subject: [PATCH 2/2] fix: fetch component name for remaining script --- packages/cli/src/contracts/LibDeploy.ejs | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/contracts/LibDeploy.ejs b/packages/cli/src/contracts/LibDeploy.ejs index d747cd1eac..45ce6f7413 100644 --- a/packages/cli/src/contracts/LibDeploy.ejs +++ b/packages/cli/src/contracts/LibDeploy.ejs @@ -60,9 +60,9 @@ library LibDeploy { if (!_reuseComponents) { IComponent comp; <% components.forEach(component => { -%> - - console.log("Deploying <%= component %>"); - comp = new <%= component %>(address(result.world)); + <% const componentName=component.split("/").pop(); %> + console.log("Deploying <%= componentName %>"); + comp = new <%= componentName %>(address(result.world)); console.log(address(comp)); <% });-%> } @@ -76,7 +76,8 @@ library LibDeploy { SystemStorage.init(result.world, result.world.components()); <% initializers.forEach((name) => { -%> - <%= name -%>.init(result.world); + <% const initializerName=name.split("/").pop(); %> + <%= initializerName -%>.init(result.world); <% }); -%> } } @@ -102,17 +103,19 @@ library LibDeploy { ISystem system; IUint256Component components = world.components(); <% systems.forEach(system => { -%> - - console.log("Deploying <%= system.name %>"); - system = new <%= system.name %>(world, address(components)); - world.registerSystem(address(system), <%= system.name %>ID); + <% const systemName=system.name.split("/").pop(); %> + console.log("Deploying <%= systemName %>"); + system = new <%= systemName %>(world, address(components)); + world.registerSystem(address(system), <%= systemName %>ID); <% system.writeAccess?.forEach(component => { -%> -<% if (component === "*") { -%> +<% const componentName=component.split("/").pop(); %> +<% if (componentName === "*") { -%> <% components.forEach(comp=> { -%> - authorizeWriter(components, <%= comp %>ID, address(system)); + <% const compName=comp.split("/").pop(); %> + authorizeWriter(components, <%= compName %>ID, address(system)); <% });-%> <% } else { -%> - authorizeWriter(components, <%= component %>ID, address(system)); + authorizeWriter(components, <%= componentName %>ID, address(system)); <% } -%> <% });-%> <% if (system.initialize) { -%>