@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,234 @@
1
+ /*
2
+ * gitter.nlg
3
+ * Naanlib/frameworks/node
4
+ *
5
+ * Git command line wrapper for NodeJS.
6
+ *
7
+ * column positioning: // // !
8
+ *
9
+ * Copyright (c) 2020-2021 by Richard C. Zulch
10
+ *
11
+ */
12
+
13
+
14
+ /*
15
+ * Gitter
16
+ *
17
+ * Access to the Git source control system. Methods take a callback, which if not provided will
18
+ * cause execution to block until complete. The return value is always a tuple of (error, data).
19
+ *
20
+ */
21
+
22
+ closure Gitter(fs, local gitt) {
23
+ gitt = new(object, this)
24
+ gitt.roots = {}
25
+
26
+ // repoRoot
27
+ //
28
+ // Compute the path from the fs root to the repo root.
29
+
30
+ closure repoRoot(repopath, callback, local execOptions) {
31
+ if !callback
32
+ return (syncAdapter(repoRoot, repopath))
33
+ if gitt.roots[repopath]
34
+ asyncResult(callback, false, gitt.roots[repopath])
35
+ execOptions = {
36
+ cmdargs: ["rev-parse", "--show-toplevel"]
37
+ execops: {
38
+ cwd: repopath
39
+ }
40
+ outLE: "\x00" // lines delimited by nulls
41
+ }
42
+ fs.execLines("git", execOptions, function(error, output) {
43
+ if !error && output.stdout.length >= 1 {
44
+ gitt.roots[repopath] = output.stdout.0.trim()
45
+ callback(false, gitt.roots[repopath]) // the first line of output is repo path
46
+ }
47
+ else
48
+ callback(Error("git rev-parse failed", error))
49
+ })
50
+ }
51
+
52
+ // bridgePath
53
+ //
54
+ // Compute the bridge path to an absolute repopath (which can point inside a repo) from the
55
+ // phyiscal repo root. If these are the same, or an error occurs, then the result is "".
56
+ //
57
+
58
+ function bridgePath(repopath, local top) {
59
+ top = repoRoot(repopath).1
60
+ if top && repopath.startsWith(top) && repopath.length > top.length
61
+ top = repopath.slice(top.length+1).concat("/") // move leading "/" of bridge path to trailing
62
+ else
63
+ "" // we are looking at the root, or an error
64
+ }
65
+
66
+ // log
67
+ //
68
+ // Report the git log history of a file in the current repository as an array of commits.
69
+ // Each element in the array has the following structure:
70
+ // {
71
+ // hash: <hash>, // abbreviated hash
72
+ // author: <author name>
73
+ // email: <author email>
74
+ // date: <author date> // can call Date(<author date>)
75
+ // message: <message> // full text, subject and body
76
+ // }
77
+ // Options are:
78
+ // {
79
+ // pathspec // string or array of strings identifying files to log
80
+ // }
81
+ //
82
+ // Sample git output to illustrate the code:
83
+ // git log --pretty=format:"%h|%an|%ae|%aI|%B" -- nide_init.nlg
84
+ // f2b54c8|Richard Zulch|richardz@zulchserver.zulch.org|2018-01-29T21:41:01-08:00|<message>
85
+ //
86
+ gitt.log = closure log(repopath, options, callback, local execOptions, result) {
87
+ if !callback
88
+ return (syncAdapter(log, repopath, options))
89
+ if !string(repopath)
90
+ return (asyncResult(callback, Error("invalid path:", repopath)))
91
+ repopath = fs.path.resolve(fs.rootpath, repopath)
92
+ execOptions = {
93
+ cmdargs: ["log", "-z", "--pretty=format:%H|%an|%ae|%aI|%B"]
94
+ execops: {
95
+ cwd: repopath
96
+ }
97
+ outLE: "\x00" // lines delimited by nulls
98
+ }
99
+ if options.pathspec
100
+ execOptions.cmdargs = execOptions.cmdargs.concat("--", options.pathspec)
101
+ result = []
102
+ execOptions.outproc = function(output, liner, kill, local line, fields) {
103
+ while (line = liner.read()) {
104
+ fields = line.split("|")
105
+ result.push({
106
+ hash: fields.0
107
+ author: fields.1
108
+ email: fields.2
109
+ date: fields.3
110
+ message: fields.slice(4).join("|") // adds back any embedded | in messages
111
+ }) }
112
+ }
113
+ fs.execLines("git", execOptions, function(error, output) {
114
+ if output.stderr
115
+ debuglog("git log stderr:", output.stderr.join("\n"))
116
+ if error
117
+ callback(Error("git log failed", error))
118
+ else if output.stderr && result.length == 0
119
+ callback(Error("git log:", output.stderr.join("\n")))
120
+ else
121
+ callback(false, result)
122
+ })
123
+ }
124
+
125
+ // status
126
+ //
127
+ // Report the git status of the current respository as an array of files. The reported paths are
128
+ // relative to the specified repopath, which may be inside the actual git repo.
129
+ // Each element in the array has the following structure:
130
+ // {
131
+ // status: <status>, // " M", "AM", "??", etc.
132
+ // path: <path>
133
+ // }
134
+ // Options are:
135
+ // {
136
+ // pathspec // string or array of strings identifying base dir
137
+ // }
138
+ //
139
+ gitt.status = closure status(repopath, options, callback, local bridge, execOptions, result) {
140
+ if !callback
141
+ return (syncAdapter(status, repopath, options))
142
+ if !string(repopath)
143
+ return (asyncResult(callback, Error("invalid path:", repopath)))
144
+ repopath = fs.path.resolve(fs.rootpath, repopath)
145
+ bridge = bridgePath(repopath)
146
+ execOptions = {
147
+ cmdargs: ["status", "-z", "--porcelain"]
148
+ execops: {
149
+ cwd: repopath
150
+ }
151
+ outLE: "\x00" // lines delimited by nulls
152
+ }
153
+ if options.pathspec
154
+ execOptions.cmdargs = execOptions.cmdargs.concat("--", options.pathspec)
155
+ result = []
156
+ execOptions.outproc = function(output, liner, kill, local line, path) {
157
+ while (line = liner.read())
158
+ if line != "" {
159
+ path = line.substring(3)
160
+ if path.startsWith(bridge) { // must start with bridge to be within repopath
161
+ path = path.slice(bridge.length)
162
+ result.push({
163
+ status: line.substring(0,2)
164
+ path: path
165
+ })
166
+ }
167
+ }
168
+ }
169
+ fs.execLines("git", execOptions, function(error, output) {
170
+ if output.stderr
171
+ debuglog("git status stderr:", output.stderr.join("\n"))
172
+ if error
173
+ callback(Error("git status failed", error))
174
+ else if output.stderr && result.length == 0
175
+ callback(Error("git status:", output.stderr.join("\n")))
176
+ else
177
+ callback(false, result)
178
+ })
179
+ }
180
+
181
+ // showfile
182
+ //
183
+ // Retrieve the content of a specific file and revision. The file pathspec must be the path of
184
+ // the file within the repo.
185
+
186
+ gitt.showfile = closure showfile(repopath, options, callback, local execOptions, result) {
187
+ if !callback
188
+ return (syncAdapter(showfile, repopath, options))
189
+ if !string(repopath)
190
+ return (asyncResult(callback, Error("invalid path:", repopath)))
191
+ if !string(options.pathspec) || !string(options.hash)
192
+ return (asyncResult(callback, Error("both pathspec and hash required:", options.pathspec, options.hash)))
193
+ repopath = fs.path.resolve(fs.rootpath, repopath)
194
+ execOptions = {
195
+ cmdargs: ["show", options.hash.concat(":", bridgePath(repopath), options.pathspec)]
196
+ execops: {
197
+ cwd: repopath
198
+ }
199
+ }
200
+ nodecp.execFile("git",
201
+ execOptions.cmdargs,
202
+ execOptions.execops,
203
+ function(err, stdout, stderr) {
204
+ if err
205
+ callback(Error("git failed", err, stderr))
206
+ else
207
+ callback(false, stdout)
208
+ }
209
+ )
210
+ }
211
+
212
+ // finis
213
+ list(false, gitt)
214
+ };
215
+
216
+
217
+ /*
218
+ * gittInit
219
+ *
220
+ * Initialize the component.
221
+ *
222
+ */
223
+
224
+ function gittInit(local manifest) {
225
+
226
+ manifest = `(Gitter, gittInit)
227
+
228
+ Naan.module.build(module.id, "gitter", function(modobj, compobj) {
229
+ require("./node.nlg")
230
+ compobj.manifest = manifest
231
+ modobj.exports.Gitter = Gitter
232
+ })
233
+
234
+ } ();
@@ -0,0 +1,81 @@
1
+ /*
2
+ * node.nlg
3
+ * Naanlib/frameworks/node
4
+ *
5
+ * Root component for node-specific functionality.
6
+ *
7
+ * column positioning: // // !
8
+ *
9
+ * Copyright (c) 2020-2021 by Richard C. Zulch
10
+ *
11
+ */
12
+
13
+
14
+ /*
15
+ * NodeStreamLiner
16
+ *
17
+ * Return a stream transformer for parsing into lines of text. The optional endings argument is
18
+ * either a RegExp or a string used to split the input into lines. Note that \r\n challenge is not
19
+ * addressed for other multiple-character line endings.
20
+ *
21
+ */
22
+
23
+ closure NodeStreamLiner(endings, local liner) {
24
+ liner = xnew(stream.Transform, {objectMode: true})
25
+ if !endings
26
+ endings = RegExp("\r\n|\r|\n")
27
+ liner.endings = endings
28
+
29
+ liner._transform = function(chunk, encoding, done, local data, lines) {
30
+ data = chunk.toString()
31
+ if (liner._lastLineData)
32
+ data = strcat(liner._lastLineData, data)
33
+ lines = data.split(liner.endings)
34
+ liner._lastLineData = lines.splice(lines.length -1, 1)[0]
35
+
36
+ // The following handles an obscure case where a two-character \r\n line ending sequence is
37
+ // split by a chunk boundary. If our chunk has at least one line then we postpone the last
38
+ // line for processing with the next chunk.
39
+ if liner._lastLineData == "" && data.charAt(data.length-1) == "\r" && lines.length > 0
40
+ liner._lastLineData = lines.splice(lines.length -1, 1)[0].concat("\r")
41
+
42
+ lines.forEach(liner.push.bind(liner))
43
+ xcall(liner, done)
44
+ }
45
+
46
+ liner._flush = function (done) {
47
+ if (liner._lastLineData)
48
+ liner.push(liner._lastLineData)
49
+ liner._lastLineData = false
50
+ xcall(liner, done)
51
+ }
52
+
53
+ liner
54
+ };
55
+
56
+
57
+ /*
58
+ * nodrInit
59
+ *
60
+ * Initialize the node module.
61
+ *
62
+ *
63
+ */
64
+
65
+ function nodrInit(local manifest) {
66
+ manifest = `(NodeStreamLiner, nodrInit)
67
+
68
+ if !js.g
69
+ throw("module frameworks/node cannot be used from a browser")
70
+ Naan.module.build(module.id, "node", function(modobj, compobj) {
71
+ require("../common/").LiveImport()
72
+ compobj.manifest = manifest
73
+ function nodrReload() {
74
+ nodecp = js.r("child_process")
75
+ fs = js.r("fs")
76
+ os = js.r("os")
77
+ stream = js.r("stream")
78
+ }()
79
+ module.reload = nodrReload
80
+ })
81
+ } ();