@naanlang/naan 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +46 -0
  3. package/dist/env_web.js +431 -0
  4. package/dist/naan.min.js +73 -0
  5. package/frameworks/browser/browser.nlg +30 -0
  6. package/frameworks/browser/pouchdb/pouchdb.min.js +7 -0
  7. package/frameworks/browser/spark-md5/spark-md5.min.js +1 -0
  8. package/frameworks/browser/sworker.js +192 -0
  9. package/frameworks/browser/terminals.nlg +787 -0
  10. package/frameworks/browser/workers.nlg +386 -0
  11. package/frameworks/client/apiclient.nlg +183 -0
  12. package/frameworks/client/client.nlg +29 -0
  13. package/frameworks/client/psm_client.nlg +572 -0
  14. package/frameworks/common/common.nlg +464 -0
  15. package/frameworks/common/preferences.nlg +131 -0
  16. package/frameworks/common/repltools.nlg +100 -0
  17. package/frameworks/common/watching.nlg +97 -0
  18. package/frameworks/node/apiserver.nlg +399 -0
  19. package/frameworks/node/filesystem.nlg +1012 -0
  20. package/frameworks/node/gitter.nlg +234 -0
  21. package/frameworks/node/node.nlg +81 -0
  22. package/frameworks/node/psm_server.nlg +465 -0
  23. package/frameworks/node/worker.nlg +560 -0
  24. package/frameworks/project/build.nlg +1229 -0
  25. package/frameworks/project/jszip.js +30 -0
  26. package/frameworks/project/jszip.nlg +87 -0
  27. package/frameworks/project/proj_cliser.nlg +139 -0
  28. package/frameworks/project/proj_console.nlg +137 -0
  29. package/frameworks/project/proj_folder.nlg +143 -0
  30. package/frameworks/project/proj_lambda.nlg +137 -0
  31. package/frameworks/project/proj_static.nlg +138 -0
  32. package/frameworks/project/project.nlg +29 -0
  33. package/frameworks/project/projects.nlg +587 -0
  34. package/frameworks/project/uglifyjs.js +1 -0
  35. package/frameworks/project/uglifyjs.nlg +79 -0
  36. package/frameworks/running/debugcom.nlg +163 -0
  37. package/frameworks/running/debugnub.nlg +565 -0
  38. package/frameworks/running/debugutil.nlg +510 -0
  39. package/frameworks/running/executors.nlg +767 -0
  40. package/frameworks/running/running.nlg +151 -0
  41. package/frameworks/running/sourcecode.nlg +346 -0
  42. package/frameworks/running/taskexec.nlg +196 -0
  43. package/frameworks/storage/dbt_pouch.nlg +773 -0
  44. package/frameworks/storage/file_manager.nlg +772 -0
  45. package/frameworks/storage/psm.nlg +326 -0
  46. package/frameworks/storage/psm_dbtables.nlg +814 -0
  47. package/frameworks/storage/resources.nlg +445 -0
  48. package/frameworks/storage/storage.nlg +52 -0
  49. package/lib/browser/env_web.js +431 -0
  50. package/lib/browser/env_webworker.js +146 -0
  51. package/lib/browser/require.js +1653 -0
  52. package/lib/core/naanlib.js +73 -0
  53. package/lib/env_node.js +282 -0
  54. package/lib/env_nodeworker.js +165 -0
  55. package/lib/node_repl.js +25 -0
  56. package/lib/node_repl_init.nlg +52 -0
  57. package/package.json +13 -0
  58. package/plugins/gitClient/clientops.nlg +317 -0
  59. package/plugins/gitClient/gitClient.nlg +63 -0
  60. package/plugins/gitClient/gitutils.nlg +1331 -0
  61. package/plugins/gitClient/minimatch.js +945 -0
  62. package/plugins/gitClient/minimatch_license.txt +15 -0
  63. package/plugins/gitClient/minimatch_readme.md +208 -0
  64. package/plugins/nodeLib/nodeLib.nlg +26 -0
  65. package/plugins/nodeLib/node_cp.nlg +65 -0
  66. package/plugins/nodeLib/node_fs.nlg +137 -0
  67. package/plugins/nodeLib/node_https.nlg +172 -0
  68. package/plugins/nodeLib/node_util.nlg +180 -0
  69. package/plugins/serviceAws/aws/aws-sdk.min.js +88 -0
  70. package/plugins/serviceAws/aws/lambda_rest_index.js +122 -0
  71. package/plugins/serviceAws/aws/lambda_rest_init.nlg +58 -0
  72. package/plugins/serviceAws/aws/lambda_ws_index.js +498 -0
  73. package/plugins/serviceAws/aws/lambda_ws_init.nlg +49 -0
  74. package/plugins/serviceAws/aws_cloudwatchlogs.nlg +122 -0
  75. package/plugins/serviceAws/aws_cognito.nlg +76 -0
  76. package/plugins/serviceAws/aws_dynamo.nlg +509 -0
  77. package/plugins/serviceAws/aws_lambda.nlg +95 -0
  78. package/plugins/serviceAws/aws_s3.nlg +134 -0
  79. package/plugins/serviceAws/aws_utils.nlg +86 -0
  80. package/plugins/serviceAws/dbt_aws.nlg +769 -0
  81. package/plugins/serviceAws/lambda_naan_control.nlg +175 -0
  82. package/plugins/serviceAws/psm_aws.nlg +258 -0
  83. package/plugins/serviceAws/serviceAws.nlg +38 -0
  84. package/plugins/serviceGitHub/gitops.nlg +522 -0
  85. package/plugins/serviceGitHub/psm_github.nlg +205 -0
  86. package/plugins/serviceGitHub/serviceGitHub.nlg +65 -0
  87. package/plugins/serviceGitLab/gitops.nlg +528 -0
  88. package/plugins/serviceGitLab/psm_gitlab.nlg +205 -0
  89. package/plugins/serviceGitLab/serviceGitLab.nlg +65 -0
  90. package/test/harness.nlg +312 -0
  91. package/test/node_test.js +33 -0
  92. package/test/test_01_core.nlg +768 -0
  93. package/test/test_02_context.nlg +269 -0
  94. package/test/test_03_jsinterop.nlg +137 -0
  95. package/test/test_04_numerics.nlg +450 -0
  96. package/test/test_05_strings.nlg +63 -0
  97. package/test/test_06_lingoparse.nlg +500 -0
  98. package/test/test_07_lingo.nlg +623 -0
@@ -0,0 +1,317 @@
1
+ /*
2
+ * clientops.nlg
3
+ * gitClient
4
+ *
5
+ * Git client for Git API services.
6
+ *
7
+ * column positioning: // // !
8
+ *
9
+ * Copyright (c) 2021 by Richard C. Zulch
10
+ *
11
+ */
12
+
13
+
14
+ /*
15
+ * GitClient
16
+ *
17
+ * An object to perform git client operations with a given Git repo and local filesystem folder.
18
+ * Both repo and directory must already exist, so create them first before creating this. Once you
19
+ * have a GitClient object, you can call connect() to ensure the filesystem is ready to hold content
20
+ * from the repo, which may modify the filesystem. Call status() to determine what changes exist.
21
+ * GitClient does not have a local copy of the repo like a normal git client. Instead it keeps
22
+ * a working tree, a staging area, and an index. There is no need for a refresh operation because it
23
+ * attempts to connect with the remote each time this object is queried. The contents of the current
24
+ * checked-out branch cannot change remotely. Only the reference names and available commits can
25
+ * change.
26
+ * Updating the current branch to the latest commit is readily accomplished by a new checkout of
27
+ * the same branch. Checkouts never overwrite modified local files, so it is safe to update or move
28
+ * to a new branch at any time. Reverting a change to a remote file requires that the remote API be
29
+ * accessible and the file(s) will be recopied. Staging a change makes an extra copy of the changed
30
+ * file in a staging area.
31
+ * Merging branches is not currently implemented. Instead, commit local changes, and then pull
32
+ * the repo into a different client elsewhere for merging and conflict resolution.
33
+ *
34
+
35
+ /ch gitClient
36
+
37
+ rr = App.nide.locate.connect("04d1e9aa-d154-4e99-b60f-3a67d4033ac4", "GitAPI").1;
38
+ glr = rr.repo(rr.repolist().1.1).1;
39
+ gc = GitClient(glr).1;
40
+ fs = App.nide.locate.connect("Host", "NideFS", "/Users/richardz/temp/").1;
41
+ gc.connect(fs, "gitlablip");
42
+
43
+ fst = fs.tree("gitlablip");
44
+ gc.gtree.refresh();
45
+ grt = glr.tree();
46
+ gc.gtree.sync(grt);
47
+ gc.gtree.gittree;
48
+
49
+ gc.gtree.fetch(false, closure(shaRepo, shaStage, path) {
50
+ glr.showfile(shaRepo)
51
+ });
52
+ gc.gtree.gittree;
53
+
54
+ gc.gtree.status({untracked:true,unchanged:true,ignored:true});
55
+ *
56
+ *
57
+ */
58
+
59
+ closure GitClient(repo, local gitc) {
60
+ gitc = new(object, this)
61
+ gitc.repo = repo
62
+ gitc.gtree = GitTree()
63
+
64
+ // refresh
65
+ //
66
+ // Refresh the current working directory for the specified operation, returning false on success
67
+ // else an error.
68
+ //
69
+ function refresh(command, local error, result) {
70
+ if !gitc.connected
71
+ return (list(Error(command.concat(" failed: tree not connected"))))
72
+ `(error, result) = gitc.gtree.refresh()
73
+ if error
74
+ return (list(Error(command.concat(" failed: cannot refresh working directory"), error)))
75
+ false
76
+ }
77
+
78
+ // notlive
79
+ //
80
+ // Ensure the repo is live, returning false. Otherwise return the error.
81
+ //
82
+ function notlive(command, local error, result) {
83
+ if !gitc.connected
84
+ return (list(Error(command.concat(" failed: tree not connected"))))
85
+ `(error, result) = repo.validate()
86
+ if error
87
+ return (list(Error(command.concat(" failed: cannot access remote repository"), error)))
88
+ false
89
+ }
90
+
91
+ // connect
92
+ //
93
+ // Connect the repo to the filesystem working directory at the specified path. This will create
94
+ // a .ngit folder in the working directory if not yet present. This still works if the remote
95
+ // repo is unavailable, but only status and staging commands are available in that case.
96
+ //
97
+ gitc.connect = function connect(fs, reporoot, local error, result) {
98
+ `(error, result) = gitc.gtree.init(fs, reporoot)
99
+ if !error
100
+ gitc.connected = true
101
+ list(error, result)
102
+ }
103
+
104
+ // disconnect
105
+ //
106
+ // Disconnect the filesystem from the repo.
107
+ //
108
+ gitc.disconnect = function disconnect() {
109
+ gitc.connected = false
110
+ list(false, { ok: true })
111
+ }
112
+
113
+ // checkout
114
+ //
115
+ // Check out the specified branch to the filesystem, leaving locally modified files unchanged.
116
+ // This operates by performing a sync with update, after which the following status changes
117
+ // occur:
118
+ //
119
+ // Current State | In New Branch | Not in New Branch
120
+ // ---------------------|----------------------|-----------------------
121
+ // unchanged | unchanged | (not present)
122
+ // unversioned | modified | unversioned
123
+ // modified | modified | unversioned
124
+ // missing | missing | (not present)
125
+ // modified-staged | modified-staged | added
126
+ // added | modified-staged | added
127
+ // added-modified | modified-staged | added-modified
128
+ // removed | removed | (not present)
129
+ // (not present) | unchanged | (not present)
130
+ //
131
+ // It's possible that round-trip sync to a new and then back to an original branch will not
132
+ // leave the working tree in exactly the same state because an user-modified file can become
133
+ // unchanged if the new branch has an identical copy. If staged files become unmodified then
134
+ // the files remain staged, though they will not be committed in that state.
135
+ //
136
+ gitc.checkout = function checkout(branch, local error, result, tree, obsoletes) {
137
+ if refresh("checkout")
138
+ return // local repo refresh failed
139
+ if notlive("checkout")
140
+ return // can't access remote git API
141
+ `(error, result) = gitc.gtree.refresh() // refresh for filesystem changes
142
+ if !error {
143
+ if branch
144
+ options = { ref: branch }
145
+ `(error, tree) = repo.tree(options)
146
+ }
147
+ if !error {
148
+ obsoletes = gitc.gtree.sync(tree)
149
+ `(error, result) = gitc.gtree.vacate(obsoletes) }
150
+ if !error
151
+ `(error, result) = gitc.gtree.fetch(false , closure(shaRepo, path) {
152
+ repo.showfile(shaRepo) // fetch a file (async)
153
+ })
154
+ if error
155
+ return (list(Error("checkout failed: error fetching remote content", error)))
156
+ list(false, { ok: true })
157
+ }
158
+
159
+ // branch
160
+ //
161
+ // Create a branch for the specified ref, or by default the current HEAD.
162
+ //
163
+ gitc.branch = function branch(name, ref) {
164
+ if notlive("branch")
165
+ return // can't access remote git API
166
+ throw("GitClient.branch not implemented") // ### to be implemented
167
+ }
168
+
169
+ // delbranch
170
+ //
171
+ // Delete the named branch.
172
+ //
173
+ gitc.delbranch = function delbranch(name) {
174
+ if notlive("delbranch")
175
+ return // can't access remote git API
176
+ throw("GitClient.delbranch not implemented") // ### to be implemented
177
+ }
178
+
179
+ // status
180
+ //
181
+ // Report the status of the working tree and staging area relative to the currently checked out
182
+ // repo branch. This does not require the repo to be available because its state is cached.
183
+ //
184
+ gitc.status = function status() {
185
+ if refresh("status")
186
+ return // local repo refresh failed
187
+ list(false, gitc.gtree.status({untracked:true,unchanged:true,ignored:true}))
188
+ }
189
+
190
+ // stage
191
+ //
192
+ // Stage any changes among the array of pathnames, which may overwrite existing staged files.
193
+ //
194
+ gitc.stage = function stage(filelist) {
195
+ if refresh("stage")
196
+ return // local repo refresh failed
197
+ gitc.gtree.stage(filelist)
198
+ }
199
+
200
+ // unstage
201
+ //
202
+ // Unstage the specified files. The actual files will be removed during a future gc operation.
203
+ //
204
+ gitc.unstage = function unstage(filelist) {
205
+ if refresh("unstage")
206
+ return // local repo refresh failed
207
+ gitc.gtree.unstage(filelist)
208
+ }
209
+
210
+ // discard
211
+ //
212
+ // Discard changes to the specified files, including restoring deleted files. If tostage is true
213
+ // the the files will be restored to the staged state if it exists, or left unchanged otherwise.
214
+ // If tostage is false then the files will be restored to the repo state.
215
+ //
216
+ gitc.discard = function discard(filelist, tostage, local error, tofetch, result) {
217
+ if refresh("revert")
218
+ return // local repo refresh failed
219
+ if notlive("revert")
220
+ return // can't access remote git API
221
+ `(error, tofetch) = gitc.gtree.discard(filelist, tostage)
222
+ if !error
223
+ `(error, result) = gitc.gtree.fetch(tofetch, closure(shaRepo, shaStage, path) {
224
+ if tostage
225
+ gitc.gtree.readstage(shaStage) // discard to stage
226
+ else
227
+ repo.showfile(shaRepo) // discard to repo
228
+ })
229
+ if error
230
+ list(error)
231
+ else
232
+ list(false, { ok: true })
233
+ }
234
+
235
+ // commit
236
+ //
237
+ // Commit changes to the repo on the current branch. If a filelist is specified then only the
238
+ // listed files are committed. Any staged files are committed from the staging area, leaving
239
+ // the working tree untouched.
240
+ //
241
+ gitc.commit = function commit(message, filelist, local comitinfo) {
242
+ if refresh("commit")
243
+ return // local repo refresh failed
244
+ if notlive("commit")
245
+ return // can't access remote git API
246
+ comitinfo = gitc.gtree.getcommit({
247
+ staged: staged
248
+ moveok: repo.info
249
+ })
250
+ // ### upload blobs and tree
251
+ // ### perform commit
252
+ }
253
+
254
+ // tag
255
+ //
256
+ // Create a tag for the current commit or optional reference, with optional message.
257
+ //
258
+ gitc.tag = function tag(tagname, ref, message) {
259
+ if notlive("tag")
260
+ return // can't access remote git API
261
+ throw("GitClient.tag not implemented") // ### to be implemented
262
+ }
263
+
264
+ // untag
265
+ //
266
+ // Delete the specified tag(s).
267
+ //
268
+ gitc.untag = function untag(tagnames) {
269
+ if notlive("untag")
270
+ return // can't access remote git API
271
+ throw("GitClient.untag not implemented") // ### to be implemented
272
+ }
273
+
274
+ // log
275
+ //
276
+ // Report the commit history for the specified filepath.
277
+ //
278
+ gitc.log = function log(filepath) {
279
+ if notlive("log")
280
+ return // can't access remote git API
281
+ repo.commits(filepath)
282
+ }
283
+
284
+ // reflist
285
+ //
286
+ // Report all named references, including branches and tags.
287
+ //
288
+ gitc.reflist = function reflist() {
289
+ if notlive("reflist")
290
+ return // can't access remote git API
291
+ throw("GitClient.reflist not implemented") // ### to be implemented
292
+ }
293
+
294
+ // finis
295
+
296
+ list(false, gitc)
297
+ };
298
+
299
+
300
+ /*
301
+ * gcopInit
302
+ *
303
+ * Initialize the gitops module.
304
+ *
305
+ */
306
+
307
+ function gcopInit(local manifest) {
308
+
309
+ manifest = `(GitClient, gcopInit)
310
+
311
+ Naan.module.build(module.id, "gitops", function(modobj, compobj) {
312
+ require("./gitClient.nlg")
313
+ compobj.manifest = manifest
314
+ modobj.exports.GitClient = GitClient
315
+ })
316
+
317
+ }();
@@ -0,0 +1,63 @@
1
+ /*
2
+ * gitClient.nlg
3
+ * gitClient
4
+ *
5
+ * A git client for API-based Git services.
6
+ *
7
+ * column positioning: // // !
8
+ *
9
+ * Copyright (c) 2021 by Richard C. Zulch
10
+ *
11
+ */
12
+
13
+
14
+ /*
15
+ * gitcRequireJS
16
+ *
17
+ * Load a Javascript file from our origin with callback(error, xobject) when complete. If no
18
+ * callback is provided then this blocks the caller and returns a standard `(result, error) tuple
19
+ * when complete.
20
+ *
21
+ * gitcRequireJS("plugins/gitClient/minimatch.js")
22
+ *
23
+ */
24
+
25
+ closure gitcRequireJS(script, callback, local scriptTag) {
26
+ if !callback
27
+ return (syncAdapter(gitcRequireJS, script))
28
+ scriptTag = js.w.document.createElement("script")
29
+ scriptTag.src = js.w.location.origin.concat("/", script)
30
+ scriptTag.onload = function (event) {
31
+ callback(false, scriptTag)
32
+ true
33
+ }
34
+ scriptTag.onerror = function (event) {
35
+ callback(Error("gitcRequireJS failed:", script))
36
+ true
37
+ }
38
+ js.w.document.body.appendChild(scriptTag)
39
+ };
40
+
41
+
42
+ /*
43
+ * gitcInit
44
+ *
45
+ * Initialize the module.
46
+ *
47
+ */
48
+
49
+ function gitcInit(local manifest) {
50
+ manifest = `(gitcRequireJS, gitcInit)
51
+
52
+ Naan.module.build(module.id, "gitClient", function(modobj, compobj) {
53
+ compobj.manifest = manifest
54
+ })
55
+ nideCommon = require("nideCommon/nideCommon.nlg")
56
+ letimport(nideCommon)
57
+ require("plugins/gitClient/clientops.nlg")
58
+ require("plugins/gitClient/gitutils.nlg")
59
+ gitcRequireJS("plugins/gitClient/minimatch.js", function(error, result) {
60
+ if error
61
+ ErrorDebugLog(error)
62
+ })
63
+ } ();