forked from newspeaklanguage/newspeak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeploymentManager.ns
655 lines (635 loc) · 23.6 KB
/
DeploymentManager.ns
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
Newspeak3
'Root'
class DeploymentManager usingPlatform: p <HopscotchPlatform> ide: webIDE <HopscotchWebIDE> (* :exemplar: ide deployment *) = (
(*
This class manages deployment of Newspeak applications from the IDE.
It maintains a set of Newspeak platform configurations. Configurations can vary
depending on the capabilities a deployed application requires. For example, an
application may or may not need the hopscotch UI, or mirrors for reflection,
or access to local functionality via node etc. A DeploymentConfiguration describes
a particular set of required capabilities.
Every configuration is based upon a base platform, which currently is either
primordial soup or javascript. This base is then extended with specific capabilities
as described above.
A customized platform class is produced based on a given deployment configuration.
Platform classes are created dynamically from source. The source is composed
dynamically from snippets describing the various platform capabilities.
We keep the set of existing configurations in the slot knownConfigurations.
This set may be extended or restricted via the UI.
*)
|
(* imports *)
private StringBuilder = p kernel StringBuilder.
private Map = p collections Map.
private List = p collections List.
private Subject = p hopscotch Subject.
private ProgrammingPresenter = webIDE browsing ProgrammingPresenter.
private ClassMirror = p mirrors ClassMirror.
private ClassDeclarationBuilder = p mirrors ClassDeclarationBuilder.
private CombinatorialParsing = webIDE namespacing manifest CombinatorialParsing.
private Grammar = webIDE namespacing manifest NewspeakGrammar.
private ASTs = webIDE namespacing manifest NewspeakASTs.
private Parsing = webIDE namespacing manifest NewspeakParsing.
private Generation = webIDE namespacing manifest JavascriptGeneration.
private Compilation = webIDE namespacing manifest Newspeak2JSCompilation
mixinApply: webIDE namespacing manifest NewspeakCompilation.
private Snapshotter = p operatingSystem = 'emscripten' ifTrue: [p victoryFuel Snapshotter].
public Runtime = webIDE namespacing manifest RuntimeForJS.
public RuntimeWithMirrorBuilders = webIDE namespacing manifest RuntimeForJSWithMirrorBuilders.
Preloader = (webIDE namespacing manifest WebCompiler packageUsing: webIDE namespacing manifest) Preloader.
(* module variables *)
ide = webIDE.
root = webIDE namespacing Root.
icons = root at: 'Icons'.
knownConfigurations <Map[String, DeploymentConfiguration]> = Map new.
maxConfig <Integer> = 0. (* counter for generating config names *)
jsPackagerSlot <JSPackager>
webFiles = webIDE webFiles.
|
createDefaultConfigurations.
) (
class DeploymentConfiguration (* :exemplar: DeploymentConfiguration new *) = (
|
public name <String>
public base <Symbol> ::= #Psoup.
public hasHopscotch <Boolean> ::= false.
public hasMirrors <Boolean> ::= false.
public hasNode <Boolean> ::= false.
public hasElectron <Boolean> ::= false.
public hasZircon <Boolean> ::= false.
public runtime <Class>
|
) (
public isKindOfDeploymentConfiguration ^ <Boolean> = (
^true
)
public hash ^ <Integer> = (
^base hash bitXor: (
hasHopscotch hash bitXor: (
hasMirrors hash bitXor: (
hasNode hash bitXor: (
hasElectron hash bitXor: (
hasZircon hash
)))))
)
public = other <Object> ^ <Boolean> = (
other isKindOfDeploymentConfiguration ifFalse: [^false].
^base = other base and: [
hasHopscotch = other hasHopscotch and: [
hasMirrors = other hasMirrors and: [
hasNode = other hasNode and: [
hasElectron = other hasElectron and: [
hasZircon = other hasZircon
]]]]]
)
) : (
)
public class DeploymentConfigurationSubject onModel: dc <DeploymentConfiguration> = Subject onModel: dc (
) (
public createPresenter ^ <DeploymentConfigurationPresenter> = (
^DeploymentConfigurationPresenter onSubject: self
)
jsPlatformFactoryPrefix ^ <String> = (
^'public class Platform usingVmMirror: vmmirror = (
|
public kernel = Object enclosingObject. (* Instantiated specially to avoid bootstrapping issues. *)
public actors = Future computing: [Actors usingPlatform: self].
public js = Future computing: [Aliens usingPlatform: self].
public collections = Future computing: [Collections usingPlatform: self].
public streams = Future computing: [Streams usingPlatform: self].
public operatingSystem = #web.
'
)
public addZircon ^ <Boolean> = (
^config hasZircon: true
)
public addHopscotch ^ <Boolean> = (
^config hasHopscotch: true
)
public addMirrors ^ <Boolean> = (
^config hasMirrors: true
)
public addElectron ^ <Boolean> = (
^config hasElectron: true
)
public addNode ^ <Boolean> = (
^config hasNode: true
)
basePlatformFactoryPrefix ^ <String> = (
config base = #Psoup ifTrue: [^psoupPlatformFactoryPrefix].
^jsPlatformFactoryPrefix
)
basePrefix ^ <String> = (
config base = #Psoup ifTrue: [^psoupPrefix].
^jsPrefix
)
public setBase: base = (
config base: base.
base = #Javascript ifTrue: [config hasZircon: false].
)
public name: n <String> = (
config name: n.
)
public name ^ <String> = (
config name isNil ifTrue: [
config name: generateConfigName
].
^config name
)
generateConfigName ^ <String> = (
maxConfig:: maxConfig + 1.
^'depConfig', maxConfig printString
)
public config ^ <DeploymentConfiguration> = (
^model
)
psoupPlatformFactoryPrefix ^ <String> = (
^'public class Platform internalKernel: ik = (|
public kernel = Kernel wrapping: ik.
public collections = Collections usingInternalKernel: ik.
public victoryFuel = PrimordialFuel usingPlatform: self internalKernel: ik.
public actors = Actors usingPlatform: self.
public js = JS usingPlatform: self.
'
)
addIsKindOfMethodsTo: src <StringBuilder> = (
src add: ' public isKindOfPlatform ^ <Boolean> = (^true)
'.
src add: 'public isKindOf'.
src add: config base.
src add: 'Platform ^ <Boolean> = (^true)
'.
config hasHopscotch ifTrue: [src add: 'public isKindOfPlatformWithHopscotch ^ <Boolean> = (^true)
'].
config hasMirrors ifTrue: [src add: 'public isKindOfPlatformWithMirrors ^ <Boolean> = (^true)
'].
config hasNode ifTrue: [src add: 'public isKindOfPlatformWithNode ^ <Boolean> = (^true)
'].
config hasElectron ifTrue: [src add: 'public isKindOfPlatformWithElectron ^ <Boolean> = (^true)
'].
config hasZircon ifTrue: [src add: 'public isKindOfPlatformWithZircon ^ <Boolean> = (^true)
'].
)
platformSuffix ^ <String> = (
config base = #Psoup ifTrue: [^psoupPlatformSuffix].
^jsPlatformSuffix
)
baseSuffix ^ <String> = (
^'
) : (
public keepsSources ^ <Boolean> = (
^', config hasMirrors printString, '
)
)'
)
psoupPlatformSuffix ^ <String> = (
^'public operatingSystem ^<String> = (
(* :literalmessage: primitive: 99 *)
halt.
)
public isKindOfPlatformWithElectron ^ <Boolean> = (
#BOGUS yourself.
^true (* well, for most apps *)
)
)'
)
images = (
^'class Images packageUsing: manifest = (
|
public accept16px = manifest accept16px.
public cancel16px = manifest cancel16px.
public backImage = manifest hsBackImage.
public clearImage = manifest clearImage.
public disclosureClosedImage = manifest disclosureClosedImage.
public disclosureOpenImage = manifest disclosureOpenImage.
public downloadImage = manifest downloadImage.
public dropDownImage = manifest hsDropdownImage.
public forwardImage = manifest hsForwardImage.
public helpImage = manifest helpImage.
public historyImage = manifest hsHistoryImage.
public homeImage = manifest hsHomeImage.
public itemReferencesImage = manifest itemReferencesImage.
public newImage = manifest hsNewImage.
public refreshImage = manifest hsRefreshImage.
|
)()
'
)
mirrorImport ^ <String> = (
config base = #Psoup ifTrue: [^' private Mirrors = manifest MirrorsForPrimordialSoup.
'].
^ ' private Mirrors = manifest MirrorsForJS.
'
)
public source ^ <String> = (
(* compute the source code for a runtime class that matches this configuration *)
| src <StringBuilder> = StringBuilder new: 2500. |
src add: basePrefix.
config hasMirrors ifTrue: [src add: mirrorImport].
config hasNode ifTrue: [].
config hasElectron ifTrue: [].
config hasZircon ifTrue: [src add: 'private Zircon = manifest Zircon.
'].
config hasHopscotch ifTrue: [src add: 'private Graphics = manifest GraphicsForHTML5.
private Fonts = manifest FontsForHTML5.
private TextModule = manifest TextModule.
private Hopscotch = manifest HopscotchForHTML5.
private images = Images packageUsing: manifest.
'].
src add: '
|
) (
'.
config hasHopscotch ifTrue: [src add: images].
src add: basePlatformFactoryPrefix.
config hasHopscotch ifTrue: [src add: ' public graphics = Graphics usingPlatform: self.
public text = TextModule usingPlatform: self.
public hopscotch = Hopscotch usingPlatform: self images: images.
'].
config hasMirrors ifTrue: [
config base = #Psoup
ifTrue: [src add: 'public mirrors = Mirrors usingPlatform: self internalKernel: ik namespace: outer Runtime.']
ifFalse: [src add: 'public mirrors = Future computing: [Mirrors usingPlatform: self runtime: outer Runtime vmMirror: vmmirror].']
].
config hasNode ifTrue: [].
config hasElectron ifTrue: [].
config hasZircon ifTrue: [
assert: [base = #Psoup] message: 'Cannot combine Zircon and Javascript base platform'.
src add: 'public zircon = Zircon usingPlatform: self.'
].
src add: '
|
) (
'.
addIsKindOfMethodsTo: src.
src add: platformSuffix.
src add: baseSuffix.
^src asString
)
public isKindOfDeploymentConfigurationSubject ^ <Boolean> = (
^true
)
isMyKind: s <Subject> ^ <Boolean> = (
^s isKindOfDeploymentConfigurationSubject
)
jsPlatformSuffix ^ <String> = (
^'
public Exception = (
^Error
)
public Message = (
^kernel Message
)
public MessageNotUnderstood = (
^kernel MessageNotUnderstood
)
public UnhandledError = (
^Error
)
)'
)
public saveConfiguration = (
config runtime: runtime.
addConfig: config
)
runtimeConfigDescription ^ <String> = (
| s = StringBuilder new: 70. |
s add: 'Configuration with'.
config hasHopscotch ifTrue: [s add: ' Hopscotch'].
config hasMirrors ifTrue: [s add: ' Mirrors'].
config hasNode ifTrue: [s add: ' Node'].
config hasElectron ifTrue: [s add: ' Electron'].
config hasZircon ifTrue: [s add: ' Zircon
'].
^s asString
)
psoupPrefix ^ <String> = (
| s = StringBuilder new: 500. |
s add: 'class Runtime packageRuntimeUsing: manifest = (
(* Provides the platform object for Newspeak on Psoup.
'.
s add: runtimeConfigDescription.
s add: '
Copyright 2012 Google Inc.
Copyright 2013 Ryan Macnak
Licensed under the Apache License, Version 2.0 (the ''License''); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*)
|
private Kernel = manifest Kernel.
public InternalKernel = manifest KernelForPrimordialSoup.
private Collections = manifest CollectionsForPrimordialSoup.
private Actors = manifest ActorsForPrimordialSoup.
private PrimordialFuel = manifest PrimordialFuel.
private JS = manifest JSForPrimordialSoup.
'.
^s asString
)
jsPrefix ^ <String> = (
| s = StringBuilder new: 500. |
s add: 'class Runtime packageUsing: manifest = (
(* Provides the platform object for Newspeak on Javascript.
'.
s add: runtimeConfigDescription.
s add: '
Copyright 2012 Google Inc.
Copyright 2013 Ryan Macnak
Licensed under the Apache License, Version 2.0 (the ''License''); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 *)
|
private Kernel = manifest KernelForJS.
private Actors = manifest ActorsForJS.
private Aliens = manifest AliensForJS.
private Collections = manifest Collections.
public MirrorGroups = manifest MirrorGroups.
private Streams = manifest Streams.
'.
^s asString.
)
public runtime ^ <ClassDeclarationMirror> = (
^(ClassDeclarationBuilder fromSource: source) install applyToObject reflectee
(*^(ide installFromBuilders: {ClassDeclarationBuilder fromSource: source}) first declaration applyToObject reflectee*)
)
) : (
)
class DeploymentConfigurationPresenter onSubject: s <DeploymentConfigurationSubject> = ProgrammingPresenter onSubject: s (
) (
public isKindOfDeploymentConfigurationPresenter ^ <Boolean> = (
^true
)
isMyKind: other <Fragment> ^ <Boolean> = (
^other isKindOfDeploymentConfigurationPresenter
)
definition ^ <Fragment> = (
^column: {
label: 'Deployment Configuration: ', subject name.
label: 'Base = ', subject config base.
subject config base = #Psoup ifTrue: [
button: 'Switch to Javascript' action: [updateGUI: [subject setBase: #Javascript]]
] ifFalse: [
button: 'Switch to Psoup' action: [updateGUI: [subject setBase: #Psoup]]
].
subject config hasHopscotch ifTrue: [
button: 'Remove Hopscotch support' action: [updateGUI: [subject config hasHopscotch: false]].
] ifFalse: [
button: 'Add Hopscotch support' action: [updateGUI: [subject config hasHopscotch: true]].
].
subject config hasMirrors ifTrue: [
button: 'Remove Mirror support' action: [updateGUI: [subject config hasMirrors: false]].
] ifFalse: [
button: 'Add Mirror support' action: [updateGUI: [subject config hasMirrors: true]].
].
subject config hasNode ifTrue: [
button: 'Remove Node support' action: [updateGUI: [subject config hasNode: false]].
] ifFalse: [
button: 'Add Node support' action: [updateGUI: [subject config hasNode: true]].
].
subject config hasElectron ifTrue: [
button: 'Remove Electron support' action: [updateGUI: [subject config hasElectron: false]].
] ifFalse: [
button: 'Add Electron support' action: [updateGUI: [subject config hasElectron: true]].
].
(subject config base = #Psoup and: [subject config hasZircon]) ifTrue: [
button: 'Remove Zircon support' action: [updateGUI: [subject config hasZircon: false]].
] ifFalse: [
button: 'Add Zircon support' action: [updateGUI: [subject config hasZircon: true]].
].
button: 'Save' action: [subject saveConfiguration].
}
)
) : (
)
public class JSPackager usingPlatform: p = (|
private parserLib = CombinatorialParsing usingPlatform: p.
private grammar = Grammar usingPlatform: p parsers: parserLib.
private asts = ASTs usingPlatform: p.
private parsing = Parsing usingPlatform: p grammar: grammar asts: asts.
private generation = Generation usingPlatform: p.
private compilation = Compilation
usingPlatform: p
asts: asts
parsing: parsing
generation: generation.
|) (
class ManifestForJS usingNamespace: ns = (|
namespace = ns.
public (* bogus *) imports = List new.
|) (
protected doesNotUnderstand: message = (
imports add: message selector.
^namespace
at: message selector
ifAbsent: [super doesNotUnderstand: message]
)
) : (
)
class JSDeployment named: n <String> page: p <String> script: s <String> source: src <String> resources: rs <List[String]> = (
(*
A Javascript deployment of an app named X consists of a script file, X.js (the code), a sources file X.sources.js (the Newspeak source code), an html file, X.html (the actual web page), and resources files.
The contents of the script, sources and HTML file are held in thes lots script, sources and page respectively.
The file names for these three, as well as for resources files, are given as a list of relative paths held in the slot resourcePaths.
*)
|
public name <String> = n.
public page <String> = p.
public script <String> = s.
public sources <String> = src.
public resourcePaths <List[String]> = rs.
|
) (
) : (
)
private extractSourcesFromConfiguration: appDefn <Class> usingNamespace: ns ^ <Array[String]> = (
(* Ordering is important: the app definition must come first *)
|
modules <List[String]> = List new.
importsRecorder = ManifestForJS usingNamespace: ns.
|
modules add: (sourceOf: appDefn).
appDefn packageUsing: importsRecorder.
importsRecorder imports do: [:import <Symbol> |
| resource |
resource:: ns at: import.
resource isKindOfBehavior ifTrue: [modules include: (sourceOf: (resource))]].
^modules asArray
)
private extractResourcesFromConfiguration: config usingNamespace: ns into: builder ^ <List[String]> = (
|
resourcePaths <List[String]> = List new.
importsRecorder = ManifestForJS usingNamespace: ns.
|
config packageUsing: importsRecorder.
importsRecorder imports do: [:import <Symbol> |
| resource |
resource:: ns at: import.
resource isKindOfString ifTrue:
[builder addStringResource: resource under: import].
(resource isKindOfJSAlien and: ['IMG' = (resource at: 'nodeName')]) ifTrue:
[
builder addImageResource: import, '.png' under: import.
resourcePaths add: import, '.png']].
^resourcePaths
)
pageNamed: name <String> ^ <String> = (
(* Compute the contents of the HTML file for the app named #name *)
| page <String> = StringBuilder new. |
page add: '<!DOCTYPE html><html><head>'; add: String lf.
page add: '<meta charset="utf-8"/>'; add: String lf.
page add: '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">';
add: String lf.
page add: '<title>'; add: name; add: '</title>'; add: String lf.
page add: '</head><body>'; add: String lf.
page add: '<script type="text/javascript" src="CodeMirror/lib/codemirror.js"></script>'.
page add: '<link rel="stylesheet" href="CodeMirror/lib/codemirror.css"></link>'.
page add: '<script type="text/javascript" src="CodeMirror/addon/display/autorefresh.js"></script>'.
page add: '<script type="text/javascript" src="'.
page add: name.
page add: '.sources.js"></script><script type="text/javascript" src="'.
page add: name.
page add: '.js"></script></body></html>'.
^page asString
)
public packageApplicationConfiguration: config <Class> withRuntimeConfiguration: rtConfig usingNamespace: ns ^ <JSDeployment> = (
(*
This method is the gateway for JS deployment. It takes an app class and a runtime class, and returns an object
describing the deployment (see class JSDeployment).
*)
|
name <String> = config name.
builder = compilation ProgramBuilder new.
resourcePaths <List[String]> = List new.
page <String> = pageNamed: name.
script <String>
sources <String>
|
builder runtimeSources: (extractSourcesFromConfiguration: rtConfig usingNamespace: ns).
builder applicationSources: (extractSourcesFromConfiguration: config usingNamespace: ns).
script:: builder outputProgram.
sources:: builder outputSources.
resourcePaths addAll: (extractResourcesFromConfiguration: rtConfig usingNamespace: ns into: builder).
resourcePaths addAll: (extractResourcesFromConfiguration: config usingNamespace: ns into: builder).
resourcePaths add: name, '.html'.
resourcePaths addFirst: name, '.js'. (* Maybe the browser will fetch this first? *)
resourcePaths addFirst: name, '.sources.js'.
^JSDeployment named: name page: page script: script source: sources resources: resourcePaths.
)
private sourceOf: klass <Class> ^ <String> = (
^(ClassMirror reflecting: klass) mixin declaration source
)
) : (
)
class RecordingManifest namespace: ns <Map[{String. String. String | Class}]> accessedResources: list <List[{String. String. String | Class}]> = (
(* This class is used to record the images required by an app.
Instantiating the app with an instance of this class as its manifest will record every image accessed via the manifest in the provided list, as a resource descriptor, which includes its name, type (always 'png' for now) and path. The app is of course, provided with the actual value desired.
*)
|
protected namespace <Map[{String. String. String | Class}]> = ns.
protected accessedResources <List[{String. String. String | Class}]> = list.
|
) (
protected doesNotUnderstand: message = (
| image = icons at: message selector ifAbsent: []. selector <String> = message selector. |
image isNil ifFalse: [
| path <String> = image at: #currentSrc. |
accessedResources add: {selector. 'png'. path}.
^path
].
accessedResources add: {selector. 'ns'. namespace at: selector}.
^namespace at: selector
)
) : (
)
public class PSoupPackager = (
) (
public packageApplicationConfiguration: appDef <Class> withRuntimeConfiguration: runtimeClass <Class> usingNamespace: ns ^ <ByteArray> = (
|
app <Object>
runtime <Object>
accessedResources <List> = List new.
|
runtime:: runtimeClass packageRuntimeUsing:
(RecordingManifest namespace: ns accessedResources: List new).
appDef packageUsing:
(RecordingManifest namespace: ns accessedResources: accessedResources).
app:: Preloader
resources: (Array withAll: accessedResources)
applicationConfiguration: appDef.
^Snapshotter new snapshotApp: app withRuntime: runtime keepSource: runtimeClass keepsSources.
)
public serializeClass: c <Class> = (
| bytes = Snapshotter new serialize: c. |
webFiles downloadFileName: c name, '.vfuel' fromBytes: bytes.
)
) : (
public packageApplicationConfiguration: appDef <Class> withRuntimeConfiguration: runtimeClass <Class> usingNamespace: ns ^ <ByteArray> = (
^self new packageApplicationConfiguration: appDef withRuntimeConfiguration: runtimeClass usingNamespace: ns
)
public serializeClass: c <Class> = (
^self new serialize: c
)
)
addConfig: config <DeploymentConfiguration> = (
knownConfigurations at: config name put: config.
)
public jsPackagerForPlatform: p <Platform> ^ <JSPackager> = (
jsPackagerSlot isNil ifTrue: [jsPackagerSlot:: JSPackager usingPlatform: p].
^jsPackagerSlot
)
public configurations = (
^knownConfigurations values
)
addFreshConfig: config <DeploymentConfiguration> = (
(DeploymentConfigurationSubject onModel: config) saveConfiguration
)
createPSoupMirrorConfig = (
| config = DeploymentConfiguration new. |
config hasMirrors: true.
config hasHopscotch: true.
config name: 'PSoup Hopscotch Web App w/Mirrors'.
addFreshConfig: config.
)
createJSMirrorConfig = (
| config = DeploymentConfiguration new base: 'Javascript'; yourself. |
config hasMirrors: true.
config hasHopscotch: true.
config name: 'Javascript Hopscotch Web App w/Mirrors'.
addFreshConfig: config.
)
createJSDefaultConfig = (
| config = DeploymentConfiguration new base: 'Javascript'; yourself. |
config name: 'Javascript Hopscotch Web App'.
config hasHopscotch: true.
addFreshConfig: config.
)
createPSoupDefaultConfig = (
| config = DeploymentConfiguration new. |
config name: 'PSoup Hopscotch Web App'.
config hasHopscotch: true.
addFreshConfig: config.
)
victoryFuelBytesFor: c <Class> withRuntime: runtimeClass <Class> ^ <ByteArray> = (
^PSoupPackager packageApplicationConfiguration: c withRuntimeConfiguration: runtimeClass usingNamespace: root
)
deploy: c <Class> asVictoryFuelWithRuntime: runtimeClass <Class> = (
| bytes = victoryFuelBytesFor: c withRuntime: runtimeClass. |
webFiles downloadFileName: c name, '.vfuel' fromBytes: bytes.
)
deploy: c <Class> asWebPageWithRuntime: runtimeClass <Class> = (
#BOGUS yourself.
(jsPackagerForPlatform: cachedPlatform)
packageApplicationConfiguration: c
withRuntimeConfiguration: runtimeClass
usingNamespace: root.
)
createDefaultConfigurations = (
createJSDefaultConfig.
createJSMirrorConfig.
createPSoupDefaultConfig.
createPSoupMirrorConfig.
)
public deploy: c <Class> on: dc <DeploymentConfiguration>
(* :exemplar1: deploy: class on: (knownConfigurations at: 'PSoup Hopscotch Web App') *)
= (
dc base = #Psoup ifTrue: [^deploy: c asVictoryFuelWithRuntime: dc runtime].
dc base = #Javascript ifTrue: [^deploy: c asWebPageWithRuntime: dc runtime].
)
) : (
)