Skip to content

Commit 96f1eb4

Browse files
...
1 parent 6e5e7cf commit 96f1eb4

File tree

5 files changed

+196
-4
lines changed

5 files changed

+196
-4
lines changed

Diff for: package-lock.json

+172
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"request-promise-native": "^1.0.5",
3737
"uuid": "^3.3.2",
3838
"uws": "^10.148.1",
39-
"winston": "^3.0.0"
39+
"winston": "^3.0.0",
40+
"zip-a-folder": "0.0.5"
4041
},
4142
"devDependencies": {
4243
"coffeescript": "^2.3.1"

Diff for: src/Setup.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ container.register
4545
clientIdentity: Awilix.asValue clientIdentity
4646
nodeCache: Awilix.asValue nodeCache
4747
myCache: Awilix.asValue myCache
48+
baseTemplateDirectory: Awilix.asValue 'C:\\home\\projects\\contractpen_node_client\\templates\\'
4849

4950
opts = {}
5051

Diff for: src/services/ContractTemplate.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ContractTemplate
2323
clause = new Clause(template)
2424
clause.setData jsonData
2525
n1 = clause.generateText()
26+
console.log n1
2627
n1
2728

2829
module.exports = ContractTemplate

Diff for: src/services/SetupClient.coffee

+20-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ ContractMetadata = require './ContractMetadata'
1515
ContractExecution = require './ContractExecution'
1616
ContractTemplate = require './ContractTemplate'
1717
prettyjson = require 'prettyjson'
18+
zipIt = require('zip-a-folder')
1819

1920
class SetupClient
2021

2122
constructor: (opts) ->
2223
@g = opts.graph
2324
@clientIdentity = opts.clientIdentity.uuid
2425
@container = opts.container
26+
@baseTemplateDirectory = opts.baseTemplateDirectory
2527

2628
getWorkerId: () =>
2729
@clientIdentity
@@ -68,6 +70,10 @@ class SetupClient
6870
result = await @execute directory, sampleTxtFile, requestFile, stateFile
6971
console.log result
7072

73+
program.usage('zip <folder>').command('zip <folder>').action (folder, cmd) =>
74+
console.log 'zip folder ' + folder
75+
@zipFolder folder
76+
7177
# Subscribe to server to await work events
7278
program.usage('subscribe <server ip address> <server port>').command('subscribe <server ip address> <server port>').action (serverIp, serverPort, cmd) =>
7379
console.log 'subscribe, attempting to subscribe to server for work'
@@ -77,13 +83,14 @@ class SetupClient
7783
program.parse process.argv
7884

7985
deploy: (guid, directoryToCreate) =>
86+
dir = @baseTemplateDirectory + directoryToCreate
8087
contractJson = await @fetchContractJsonFromServer guid
81-
await @createProject directoryToCreate, contractJson
88+
await @createProject dir, contractJson
8289

8390
templateProcess: (jsonData, grammar, directory) =>
84-
#t = new ContractTemplate()
8591
t = @container.resolve "ContractTemplate"
86-
await t.template(jsonData, grammar, directory)
92+
dir = @baseTemplateDirectory + directory
93+
await t.template(jsonData, grammar, dir)
8794

8895
extract: (directory, jsonFile, isMulti) =>
8996
meta = new ContractMetadata()
@@ -177,8 +184,16 @@ class SetupClient
177184
result = @export params[0], params[1]
178185
if (command == 'exportmulti')
179186
result = @export params[0], params[1]
187+
if (command == 'zip')
188+
result = @zipFolder params[0]
180189
result
181190

191+
zipFolder: (folder) =>
192+
base = @baseTemplateDirectory
193+
f = base + folder
194+
a = base + folder + '.zip'
195+
await zipIt.zip(f, a)
196+
182197
subscribeCluster: (serverId, port) =>
183198
socket = new ClusterWS(url: 'ws://localhost:3050')
184199

@@ -236,6 +251,8 @@ class SetupClient
236251

237252
# Executes all handlebars templates and places them in the destination directory
238253
createProject: (dir, contract) =>
254+
console.log 'create project'
255+
console.log dir
239256
@createDirectoryIfNotExist dir
240257
@createDirectoryIfNotExist dir + path.sep + 'grammar'
241258
@createDirectoryIfNotExist dir + path.sep + 'lib'

0 commit comments

Comments
 (0)