squared 0.3.14 → 0.4.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.
data/README.ruby.md ADDED
@@ -0,0 +1,546 @@
1
+ # squared 0.4
2
+
3
+ * [source](https://github.com/anpham6/squared)
4
+ * [manifest](https://github.com/anpham6/squared-repo)
5
+ * [docs](https://squared.readthedocs.io)
6
+
7
+ ## Version Compatibility
8
+
9
+ | Date | squared | Min | Max | Git |
10
+ | :--------: | ------: | -----: | -----: | -----: |
11
+ | 2024-12-07 | 0.1.0 | 2.4.0 | 3.3.6 | 2.39 |
12
+ | 2025-01-07 | 0.2.0 | 2.4.0 | 3.4.0 | 2.39 |
13
+ | 2025-02-07 | 0.3.0 | 2.4.0 | 3.4.1 | 2.39 |
14
+ | 2025-03-06 | 0.4.0 | 2.4.0 | 3.4.2 | 2.39 |
15
+
16
+ The range chart indicates the latest Ruby tested against at the time of release.
17
+
18
+ ## Installation
19
+
20
+ ```sh
21
+ gem install squared
22
+ ```
23
+
24
+ ### Optional
25
+
26
+ * [Repo](https://source.android.com/docs/setup/reference/repo)
27
+ * Python 3.6
28
+ * Not compatible with Windows
29
+
30
+ ```sh
31
+ mkdir -p ~/.bin
32
+ PATH="${HOME}/.bin:${PATH}"
33
+ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
34
+ chmod a+rx ~/.bin/repo
35
+ ```
36
+
37
+ ## Example - Rakefile
38
+
39
+ Projects from any accessible folder can be added relative to the parent directory (e.g. *REPO_ROOT*) or absolutely. The same Rakefile can also manage other similarly cloned `Repo` repositories remotely by setting the `REPO_ROOT` environment variable to the location. Missing projects will simply be excluded from the task runner.
40
+
41
+ ```ruby
42
+ require "squared"
43
+
44
+ require "squared/workspace"
45
+ require "squared/workspace/repo" # Optional
46
+ require "squared/workspace/project/node" #
47
+ require "squared/workspace/project/python" #
48
+ require "squared/workspace/project/ruby" #
49
+ require "squared/workspace/project/docker" #
50
+ # OR
51
+ require "squared/app" # All workspace related modules
52
+
53
+ # NODE_ENV = production
54
+
55
+ # REPO_ROOT = /workspaces |
56
+ # REPO_HOME = /workspaces/squared | Dir.pwd
57
+ # rake = /workspaces/squared/Rakefile | main?
58
+ # OR
59
+ # REPO_ROOT = /workspaces | Dir.pwd
60
+ # rake = /workspaces/Rakefile |
61
+ # REPO_HOME = /workspaces/squared | main: "squared"
62
+
63
+ # pathname = /workspaces/pathname
64
+ # optparse = /workspaces/optparse
65
+ # log = /workspaces/logger
66
+ # emc = /workspaces/e-mc
67
+ # pir = /workspaces/pi-r
68
+ # squared = /workspaces/squared
69
+ # cli = /workspaces/squared/publish/sqd-cli
70
+ # sqd-serve = /workspaces/squared/publish/sqd-serve
71
+ # sqd = /workspaces/squared/sqd
72
+
73
+ Workspace::Application
74
+ .new(Dir.pwd, main: "squared") # Dir.pwd? (main? is implicitly basename)
75
+ .banner("group", "project", styles: ["yellow", "black"], border: "bold") # name | project | path | ref | group? | parent? | version?
76
+ .repo("https://github.com/anpham6/squared-repo", "nightly", script: ["build:dev", "build:prod"], ref: :node) # Repo (optional)
77
+ .run("rake install", ref: :ruby)
78
+ .depend(false, group: "default")
79
+ .clean("rake clean", group: "default")
80
+ .clean(["build/"], group: "app")
81
+ .log({ file: "tmp/%Y-%m-%d.log", level: "debug" }, group: "app")
82
+ .add("pathname", run: "rake compile", copy: "rake install", test: "rake test", group: "default", env: { # Ruby (with C extensions)
83
+ "CFLAGS" => "-fPIC -O1"
84
+ })
85
+ .add("optparse", doc: "rake rdoc", group: "default") # Uses bundler/gem_tasks (without C extensions)
86
+ .add("logger", copy: { from: "lib", glob: "**/*.rb", into: "~/.rvm/gems/ruby-3.4.0/gems/logger-1.6.1" }, clean: ["tmp/"]) # autodetect: true
87
+ .add("e-mc", "emc", copy: { from: "publish", scope: "@e-mc", also: [:pir, "squared-express/"] }, ref: :node) # Node
88
+ .add("pi-r", "pir", copy: { from: "publish", scope: "@pi-r" }, clean: ["publish/**/*.js", "tmp/"]) # Trailing slash required for directories
89
+ .add("squared", script: ["build:stage1", "build:stage2"], group: "app") do # Copy target (main)
90
+ # Repo (global)
91
+ as(:run, "build:dev", "dev") # npm run build:dev -> npm run dev
92
+ as(:run, { "build:dev": "dev", "build:prod": "prod" })
93
+
94
+ add("publish/sqd-cli", "cli", exclude: [:git]) # rake cli:build
95
+ add("publish/sqd-serve") # rake sqd-serve:build
96
+ add("publish/sqd-admin", group: "sqd", exclude: [:base])
97
+ # OR
98
+ with(exclude: [:base]) { add("publish/*", "packages") } # rake packages:sqd-serve:build
99
+ # OR
100
+ add(["publish/sqd-cli", "publish/sqd-serve"], true, exclude: [:base]) # rake squared:sqd-serve:build
101
+ end
102
+ .add("squared/sqd", exclude: :git, pass: [:node, "checkout", "bump"]) do # Skip initialize(:node) + squared:checkout:* + squared:bump:*
103
+ variable_set :script, "build:sqd" # Override detection
104
+ variable_set :depend, false
105
+ variable_set :clean, ["build/sqd/"]
106
+ end
107
+ .with(:docker, pass: ["unpack"]) do
108
+ .add("squared", "docker", file: "Dockerfile", context: ".", tag: "latest", args: "--ssh=default", secrets: ["id=github,env=GITHUB_TOKEN"]) do # Docker
109
+ series(:clean) do # run | depend | doc | lint | test | copy | clean
110
+ File.read(basepath("docker-bake.hcl"))
111
+ .scan(/\btags\s+=\s+\["([^"]+)"\]/)
112
+ .each { |val| image(:rm, tag: val.first) }
113
+ end
114
+ end
115
+ end
116
+ .pass("pull", group: "default") { test? || doc? } # pathname:pull | optparse:pull
117
+ .style("banner", 255.255) # 256 colors (fg | fg.bg | -0.bg)
118
+ .build(default: "build", parallel: ["pull", "fetch", "rebase", "archive", "copy", "clean", /^outdated:/], pass: ["publish"]) do |workspace|
119
+ workspace
120
+ .enable_aixterm
121
+ .style({
122
+ banner: ["bright_cyan", "bold", "bright_black!"],
123
+ border: "bright_white"
124
+ })
125
+ end
126
+
127
+ # default = /workspaces/ruby/*
128
+ # pathname = /workspaces/ruby/pathname
129
+ # optparse = /workspaces/ruby/optparse
130
+ # logger = /workspaces/ruby/logger
131
+ # android = /workspaces/android-docs
132
+ # chrome = /workspaces/chrome-docs
133
+
134
+ Workspace::Application
135
+ .new(ENV["SQUARED_HOME"], prefix: "rb", common: false) # Local styles
136
+ .group("ruby", "default", run: "rake build", copy: "rake install", clean: "rake clean", ref: :ruby, override: {
137
+ pathname: {
138
+ run: "rake compile" # rake rb:pathname:build
139
+ }
140
+ })
141
+ .with(:python) do # ref=Symbol | group=String
142
+ banner([:name, ": ", :version], "path") # chrome-docs: 0.1.0 | /workspaces/chrome-docs
143
+ doc("make html") # rake rb:doc:python
144
+ run(false) # rake rb:build:python (disabled)
145
+ exclude(%i[base git]) # Project::Git.ref (superclass)
146
+ add("android-docs", "android") # rake rb:android:doc
147
+ add("chrome-docs", "chrome") # rake rb:chrome:doc
148
+ end
149
+ .style("inline", "bold")
150
+ .build
151
+ ```
152
+
153
+ **NOTE**: The use of "**ref**" (class name) is only necessary when initializing an empty directory (e.g. *rake repo:init*).
154
+
155
+ ## Archive
156
+
157
+ ```ruby
158
+ # HEADERS={"Authorization":"Bearer RANDOM-TOKEN"} (hash/json)
159
+ # ZIP_DEPTH=0 | default=1
160
+ # TAR_DEPTH=0 | TAR_DEPTH_SQUARED
161
+ # UNPACK_FORCE=1 | Remove target directory
162
+
163
+ Workspace::Application
164
+ .new(main: "squared")
165
+ .with(:python) do
166
+ add("android-docs", "android", archive: "https://github.com/anpham6/android-docs/archive/refs/tags/v0.3.0.zip")
167
+ add("chrome-docs", "chrome", archive: {
168
+ uri: "https://github.com/anpham6/chrome-docs/archive/refs/tags/v0.5.0.tar.gz", # URI.open (required)
169
+ digest: "e3d55d2004d4770dd663254c9272dc3baad0d57a5bd14ca767de6546cdf14680", # SHA1 | SHA256 | SHA384 | SHA512 | MD5
170
+ digest: "rmd160:47b7790a511eed675fec1a3e742845fef058799b", # RMD160
171
+ ext: "tar.gz", # zip | tar | tar.gz | tgz | tar.xz | txz
172
+ depth: 1, # nested directories (e.g. --strip-components)
173
+ headers: { # URI.open
174
+ "Authorization" => "Bearer RANDOM-TOKEN"
175
+ }
176
+ })
177
+ end
178
+ .add("squared", release: "https://github.com/anpham6/squared/archive/refs/tags/??") # squared:unpack:zip[v5.4.0,/tmp/squared]
179
+ end
180
+ ```
181
+
182
+ ### Clone
183
+
184
+ The task is only active when the project directory is empty or does not exist.
185
+
186
+ ```ruby
187
+ Workspace::Application
188
+ .new(main: "squared")
189
+ .git(
190
+ "emc": "https://github.com/anpham6/e-mc", # rake emc:clone
191
+ "pir": { # rake pir:clone
192
+ uri: "https://github.com/anpham6/pi-r", #
193
+ options: { #
194
+ "origin": "github", # --origin='github'
195
+ "recurse-submodules": false, # --no-recurse-submodules
196
+ "shallow-exclude": ["v0.0.1", "v0.0.2"] # --shallow-exclude='v0.0.1' --shallow-exclude='v0.0.2'
197
+ }
198
+ }
199
+ )
200
+ .git("squared", "/path/to/squared", options: { local: true }) # Relative paths resolve from workspace root
201
+ .git(
202
+ {
203
+ emc: { uri: "e-mc", options: { "depth": 2 } }, # https://github.com/anpham6/e-mc
204
+ pir: "pi-r" # Maps task alias to repository folder
205
+ },
206
+ base: "https://github.com/anpham6", # Required
207
+ repo: ["squared", "android-docs", "chrome-docs"], # https://github.com/anpham6/squared
208
+ options: { # Only "repo"
209
+ "depth": 1,
210
+ "quiet": true
211
+ }
212
+ )
213
+ .with(:node) do # rake clone:node
214
+ add("e-mc", "emc") # https://github.com/anpham6/e-mc
215
+ add("pi-r", "pir") # https://github.com/anpham6/pi-r
216
+ add("squared") # https://github.com/anpham6/squared
217
+ end
218
+ .with(:python) do # rake clone:python
219
+ add("android-docs")
220
+ add("chrome-docs") do
221
+ revbuild(include: "source/", exclude: ["source/conf.py"]) # Limit files being watched
222
+ end
223
+ end
224
+ .git("https://github.com/anpham6", ["emc", "pir"]) # Targets any defined project
225
+ .git("https://github.com/anpham6", cache: true) # Uses already defined root projects + revbuild
226
+ .revbuild # Enables task revbuild (squared.revb)
227
+ .revbuild(file: "../build.json") # $ROOT/build.json
228
+ .build(parallel: ["clone"]) # rake clone + rake clone:sync
229
+ ```
230
+
231
+ ### Graph
232
+
233
+ ```ruby
234
+ Workspace::Application
235
+ .new(main: "squared")
236
+ .graph(["depend"], ref: :git) # Optional
237
+ .with(:python) do
238
+ add("android-docs", "android")
239
+ add("chrome-docs", "chrome", graph: "android")
240
+ end
241
+ .with(:node) do
242
+ graph(["build", "copy"], on: { # Overrides "git"
243
+ first: proc { puts "1" },
244
+ last: proc { puts "2" }
245
+ })
246
+ script("build:dev") # npm run build:dev
247
+ # OR
248
+ run([nil, "build:dev", { "PATH" => "~/.bin" }, "--workspace", "--silent"]) # PATH="~/.bin" npm run build:dev --workspace -- --silent
249
+ # OR
250
+ run({ # Same
251
+ script: "build:dev", #
252
+ env: { "PATH" => "~/.bin" }, #
253
+ opts: "--workspace", #
254
+ args: "--silent" #
255
+ })
256
+
257
+ add("e-mc", "emc") do
258
+ first("build", "emc:clean", "emc:depend") # rake emc:clean && rake emc:depend && rake emc:build && echo "123"
259
+ last("build", out: "123") { |out: nil| puts out } #
260
+ error("build") { |err: nil| log.debug err } #
261
+ end
262
+ add("pi-r", "pir", graph: "emc", first: {
263
+ build: proc { puts self.name } # puts "pir"
264
+ })
265
+ add("squared-express", "express", graph: "pir")
266
+ add("squared", graph: ["chrome", "express"]) do
267
+ first("git:ls-files") { puts "1" } # skipped
268
+ first("git:ls-files", override: true) { puts "2" } # puts "2"
269
+ last("git:ls-files") { puts workspace.root } # puts "/workspaces"
270
+ end
271
+ end
272
+ .with(:ruby) do
273
+ run("gem build") # gem build
274
+ # OR
275
+ run(["gem build", "--force", { "RUBY_VERSION" => "3.4.0" }]) # RUBY_VERSION="3.4.0" gem build --force
276
+ # OR
277
+ run({ #
278
+ command: "gem build", # RUBY_VERSION="3.4.0" gem build --silent --force
279
+ opts: "--force", # composable
280
+ env: { "PATH" => "~/.bin" }, #
281
+ args: { silent: true } #
282
+ })
283
+ # OR
284
+ run(["gem pristine", ["gem build", "gem cleanup"], nil, "--debug"]) # gem pristine --debug && gem build --debug && gem cleanup --debug
285
+ #
286
+ # All commands are either Array or Hash
287
+ #
288
+ run([ # PATH="~/.bin" GEM_HOME="~/.gems/ruby-3.4.0" (merged)
289
+ ["gem pristine", "--all", { "PATH" => "~/.bin" }, "--silent"], # gem pristine --silent --all
290
+ ["gem build", { strict: true }, { "GEM_HOME" => "~/.gems/ruby-3.4.0" }] # gem build --strict
291
+ ]) #
292
+ # OR
293
+ run([ # Same
294
+ { #
295
+ env: { "PATH" => "~/.bin" }, #
296
+ command: "gem pristine", #
297
+ opts: "--all", args: "--silent" #
298
+ }, #
299
+ { #
300
+ env: { "GEM_HOME" => "~/.gems/ruby-3.4.0" }, #
301
+ command: "gem build", #
302
+ opts: { strict: true } #
303
+ } #
304
+ ])
305
+
306
+ add("pathname", test: ["rake test", { jobs: ENV["RAKE_JOBS"] }]) # rake test --jobs 4
307
+ add("fileutils", graph: "pathname")
308
+ add("optparse", run: "gem build", env: { "PATH" => "~/.bin" }, opts: "-v") # PATH="~/.bin" gem build -v
309
+ add("rake", graph: ["fileutils", "optparse"])
310
+ banner(command: false) # Always hide banner
311
+ end
312
+ .build
313
+ ```
314
+
315
+ ```sh
316
+ rake pir:graph # emc + pir
317
+ rake express:graph # emc + pir + express
318
+ rake chrome:graph # android + chrome
319
+ rake graph:python # same
320
+ rake squared:graph # android + chrome + emc + pir + express + squared
321
+ rake graph:node # same
322
+ rake rake:graph # pathname + fileutils + optparse + rake
323
+ rake graph:ruby # same
324
+ rake graph # graph:node + graph:ruby
325
+
326
+ rake squared:graph:run[express,pir] # emc + pir + express + squared
327
+ rake squared:graph:run[node,-emc] # pir + express + squared
328
+ ```
329
+
330
+ ### Batch
331
+
332
+ ```ruby
333
+ Workspace::Series.batch(:ruby, :node, {
334
+ stage: %i[graph test],
335
+ reset: %i[stash pull]
336
+ })
337
+ ```
338
+
339
+ ### Rename
340
+
341
+ ```ruby
342
+ Workspace::Series.rename("depend", "install")
343
+ ```
344
+
345
+ ## Usage
346
+
347
+ ```sh
348
+ rake -T # List tasks
349
+ rake # rake status (usually "build")
350
+
351
+ # GIT_OPTIONS=rebase
352
+ rake pull # All except "default" + "app"
353
+ rake pull:ruby # pathname + optparse + logger
354
+ rake pull:default # pathname + optparse
355
+ rake pull:app # squared
356
+ rake pull:node # emc + pir + squared
357
+
358
+ rake build # All except "android"
359
+ rake doc # optparse + android
360
+ rake depend # All except "default"
361
+
362
+ rake build:ruby # rake compile + rake install + rake install
363
+
364
+ rake clean # All except "default" + "app"
365
+ rake clean:ruby # rake clean + rake clean + ["tmp/"]
366
+ rake clean:default # rake clean + rake clean + skip
367
+ rake clean:app # none + skip + ["build/"]
368
+ rake clean:node # none + ["publish/**/*.js", "tmp/"] + ["build/"]
369
+
370
+ rake squared:run[#] # List scripts (node)
371
+ rake squared:rake[#] # List tasks (ruby)
372
+ ```
373
+
374
+ ```sh
375
+ rake build:app # squared + cli + sqd-serve
376
+ rake squared:build:workspace # cli + sqd-serve
377
+ rake pull:sqd # sqd-admin
378
+ rake squared:pull:workspace # sqd-serve + sqd-admin
379
+ rake squared:outdated:workspace # cli + sqd-serve + sqd-admin
380
+ ```
381
+
382
+ ## Methods
383
+
384
+ Task:
385
+
386
+ * run
387
+ * script
388
+ * depend
389
+ * archive
390
+ * graph
391
+ * doc
392
+ * lint
393
+ * test
394
+ * clean
395
+
396
+ Non-task:
397
+
398
+ * log
399
+ * exclude
400
+
401
+ ## Styles
402
+
403
+ * banner
404
+ * border
405
+ * header
406
+ * active
407
+ * inline
408
+ * subject
409
+ * caution
410
+ * current
411
+ * extra
412
+ * major
413
+ * red
414
+ * yellow
415
+ * green
416
+
417
+ ## Environment
418
+
419
+ ### Path
420
+
421
+ All project executable programs can have their binary path set to a non-global alias.
422
+
423
+ ```ruby
424
+ Common::PATH.merge!({
425
+ GIT: "/usr/bin/git",
426
+ TAR: "/opt/archivers/tar",
427
+ UNZIP: "/opt/archivers/unzip",
428
+ GEM: "~/.rvm/gems/ruby-3.4.0/bin/gem",
429
+ BUNDLE: "~/.rvm/gems/ruby-3.4.0/bin/bundle",
430
+ RAKE: "~/.rvm/gems/ruby-3.4.0/bin/rake",
431
+ NPM: "/opt/node/v22.0.0/bin/npm",
432
+ PYTHON: "#{ENV["PYTHONPATH"]}/bin/python"
433
+ })
434
+ ```
435
+
436
+ ### Build
437
+
438
+ ```ruby
439
+ Workspace::Application
440
+ .new
441
+ .add("squared", run: "gcc a.c -o a.o", opts: { __debug__: { g: true, O2: true, c: nil }, c: true, j: 4 }) # gcc a.c -o a.o -c -j4
442
+
443
+ BUILD_TYPE # global
444
+
445
+ # :env :run :args :opts :type
446
+ # LD_LIBRARY_PATH="path/to/lib" CFLAGS="-Wall" gcc a.c -o a.o -g -O2
447
+ BUILD_${NAME} # gcc a.c -o a.o
448
+ BUILD_${NAME}_OPTS # -g
449
+ BUILD_${NAME}_ENV # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
450
+ BUILD_${NAME}_TYPE # debug
451
+
452
+ # :env :script :opts :args
453
+ # NODE_ENV="production" NO_COLOR="1" npm run build:dev --loglevel=error --workspaces=false -- --quiet
454
+ BUILD_${NAME} # build:dev
455
+ BUILD_${NAME}_OPTS # --loglevel=error --workspaces=false
456
+ BUILD_${NAME}_ENV # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
457
+ BUILD_${NAME}_DEV # pattern,0,1 (:dev)
458
+ BUILD_${NAME}_PROD # pattern,0,1 (:prod)
459
+ ${REF}_${NAME}_OPTS # --quiet (e.g. NODE_SQUARED_OPTS)
460
+
461
+ BUILD_${NAME}=0 # skip project
462
+ ```
463
+
464
+ ### Graph
465
+
466
+ ```ruby
467
+ GRAPH_${NAME} # depend,build => squared:depend + squared:build
468
+ GRAPH_${NAME}_PASS # -emc,pir,express => pir + express
469
+ ```
470
+
471
+ ### Logger
472
+
473
+ These global options also can target the project suffix `${NAME}`. (e.g. LOG_FILE_EMC)
474
+
475
+ ```ruby
476
+ LOG_FILE # %Y-%m-%d.log
477
+ # OR
478
+ LOG_AUTO # year,y,month,m,day,d,1
479
+ # Optional
480
+ LOG_DIR # exist?
481
+ LOG_LEVEL # See gem "logger"
482
+ LOG_COLUMNS # terminal width (default: 80)
483
+ ```
484
+
485
+ ### Repo
486
+
487
+ These global options also can target the application main suffix `${NAME}`. (e.g. REPO_ROOT_SQUARED)
488
+
489
+ ```ruby
490
+ REPO_ROOT # parent dir
491
+ REPO_HOME # project dir (main)
492
+ REPO_BUILD # run,script
493
+ REPO_GROUP # string
494
+ REPO_REF # e.g. ruby,node
495
+ REPO_DEV # pattern,0,1
496
+ REPO_PROD # pattern,0,1
497
+ REPO_WARN # 0,1
498
+ REPO_SYNC # 0,1
499
+ REPO_MANIFEST # e.g. latest,nightly,prod
500
+ REPO_DRYRUN # 0,1,2
501
+ REPO_TIMEOUT # confirm dialog (seconds)
502
+ ```
503
+
504
+ ## Git
505
+
506
+ Most project classes will inherit from `Git` which enables these tasks:
507
+
508
+ | Task | Git | Command |
509
+ | :--------- | :--------------- | :-------------------------------------------- |
510
+ | branch | branch | create set delete move copy list edit current |
511
+ | checkout | checkout | commit branch track detach path |
512
+ | commit | commit | add all amend amend-orig |
513
+ | diff | diff | head cached branch files between contain |
514
+ | fetch | fetch | origin remote |
515
+ | files | ls-files | cached modified deleted others ignored |
516
+ | git | | clean mv restore rm |
517
+ | merge | merge | commit no-commit send |
518
+ | pull | pull | origin remote |
519
+ | rebase | rebase | branch onto send |
520
+ | refs | ls-remote --refs | heads tags remote |
521
+ | reset | reset | commit index patch mode |
522
+ | rev | rev | commit branch output parseopt |
523
+ | show | show | format oneline |
524
+ | stash | stash | push pop apply drop list |
525
+ | tag | tag | add delete list |
526
+
527
+ You can disable all of them at once using the `exclude` property.
528
+
529
+ ```ruby
530
+ Workspace::Application
531
+ .new
532
+ .add("squared", exclude: :git)
533
+ ```
534
+
535
+ You can disable one or more of them using the `pass` property as a *string*.
536
+
537
+ ```ruby
538
+ Workspace::Application
539
+ .new
540
+ .add("squared", pass: ["pull"], ref: :node)
541
+ .pass("pull", ref: :node) { read_packagemanager(:private) }
542
+ ```
543
+
544
+ ## LICENSE
545
+
546
+ BSD 3-Clause
data/lib/squared/app.rb CHANGED
@@ -5,4 +5,5 @@ require_relative 'workspace/repo'
5
5
  require_relative 'workspace/project/node'
6
6
  require_relative 'workspace/project/python'
7
7
  require_relative 'workspace/project/ruby'
8
+ require_relative 'workspace/project/docker'
8
9
  require_relative 'config'
@@ -13,8 +13,10 @@ module Squared
13
13
  BANNER: true,
14
14
  QUOTE: "'",
15
15
  SPACE: ' => ',
16
- GRAPH: ['', '', '', '', ''],
16
+ GRAPH: ['|', '-', '|', '\\', '-'].freeze,
17
+ BORDER: ['|', '-', '-', '-', '-', '-', '|', '|', '-', '-'].freeze,
17
18
  VIEW: 'view',
19
+ LEVEL: ENV.fetch('LOG_LEVEL', 0).to_i,
18
20
  COLOR: ENV.fetch('NO_COLOR', '').empty?
19
21
  }
20
22
  VAR = {
@@ -42,7 +44,10 @@ module Squared
42
44
  header: [:bold],
43
45
  active: [:bold],
44
46
  inline: [:bold],
47
+ subject: [:bold],
48
+ caution: [:red],
45
49
  current: nil,
50
+ extra: nil,
46
51
  major: [:bold]
47
52
  },
48
53
  project: {},
@@ -55,7 +60,6 @@ module Squared
55
60
  hash: %i[green black!],
56
61
  array: %i[blue black!],
57
62
  number: [:magenta],
58
- boolean: [:magenta],
59
63
  undefined: %i[red italic]
60
64
  },
61
65
  logger: {
@@ -86,7 +90,7 @@ module Squared
86
90
  PATH.freeze
87
91
  ARG.freeze
88
92
  VAR.each_value(&:freeze)
89
- VAR[:theme].each_value { |val| val.freeze.each_value(&:freeze) }
93
+ VAR[:theme].each_value(&:freeze)
90
94
  VAR.freeze
91
95
  end
92
96
 
@@ -96,15 +100,13 @@ module Squared
96
100
  return [] if obj.nil?
97
101
 
98
102
  unless obj.is_a?(::Array)
99
- obj = if obj.respond_to?(:to_ary)
100
- obj.to_ary
101
- elsif obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
103
+ obj = if obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
102
104
  val
103
105
  else
104
106
  [obj]
105
107
  end
106
108
  end
107
- obj = flat.is_a?(::Numeric) ? obj.flatten(flat) : obj.flatten if flat
109
+ obj = obj.flatten(flat.is_a?(::Numeric) ? flat : nil) if flat
108
110
  obj = obj.compact if compact
109
111
  obj = obj.map(&meth) if meth
110
112
  block_given? ? obj.select(&blk) : obj
@@ -54,7 +54,7 @@ module Squared
54
54
  ret.each_with_index do |opt, index|
55
55
  if opt == val
56
56
  j = index
57
- elsif j && opt =~ pat && $1 == key
57
+ elsif j && opt[pat, 1] == key
58
58
  i << index
59
59
  end
60
60
  end