squared 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ruby.md +22 -7
- data/lib/squared/common/base.rb +10 -9
- data/lib/squared/common/format.rb +2 -2
- data/lib/squared/common/task.rb +4 -3
- data/lib/squared/config.rb +30 -26
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +123 -83
- data/lib/squared/workspace/project/base.rb +53 -24
- data/lib/squared/workspace/project/git.rb +73 -66
- data/lib/squared/workspace/project/node.rb +114 -83
- data/lib/squared/workspace/project/python.rb +47 -21
- data/lib/squared/workspace/project/ruby.rb +39 -51
- data/lib/squared/workspace/repo.rb +37 -23
- data/lib/squared/workspace/series.rb +64 -40
- data/lib/squared/workspace.rb +8 -2
- data/squared.gemspec +1 -0
- metadata +16 -2
@@ -7,8 +7,6 @@ module Squared
|
|
7
7
|
include Format
|
8
8
|
include System
|
9
9
|
|
10
|
-
attr_accessor :warning
|
11
|
-
|
12
10
|
def repo(url, manifest = 'latest', run: nil, dev: nil, prod: nil, ref: @ref, group: @group)
|
13
11
|
@home = if (val = env('REPO_HOME'))
|
14
12
|
home = Pathname.new(val)
|
@@ -34,11 +32,18 @@ module Squared
|
|
34
32
|
end
|
35
33
|
@root.join(main).realdirpath
|
36
34
|
else
|
37
|
-
install?(pwd =
|
35
|
+
install?(pwd = @home) ? pwd.join(main) : pwd
|
38
36
|
end
|
39
37
|
@root = @home.parent
|
40
38
|
@manifest_url = url
|
41
39
|
@manifest = manifest
|
40
|
+
set_ref = lambda do
|
41
|
+
if group
|
42
|
+
@script[:group][:_] = group.to_s
|
43
|
+
elsif ref
|
44
|
+
@script[:ref][:_] = ref.to_sym
|
45
|
+
end
|
46
|
+
end
|
42
47
|
if repo?
|
43
48
|
@script[:build] = case (val = env('REPO_BUILD'))
|
44
49
|
when 'verbose'
|
@@ -53,8 +58,15 @@ module Squared
|
|
53
58
|
end
|
54
59
|
@script[:dev] = bool_match(env('REPO_DEV'), dev)
|
55
60
|
@script[:prod] = bool_match(env('REPO_PROD'), prod)
|
56
|
-
|
57
|
-
|
61
|
+
if (val = env('REPO_GROUP'))
|
62
|
+
@script[:group][:_] = val.to_s
|
63
|
+
@script[:env] = true
|
64
|
+
elsif (val = env('REPO_REF'))
|
65
|
+
@script[:ref][:_] = val.to_sym
|
66
|
+
@script[:env] = true
|
67
|
+
else
|
68
|
+
set_ref
|
69
|
+
end
|
58
70
|
@warning = case env('REPO_WARN')
|
59
71
|
when '0'
|
60
72
|
false
|
@@ -68,22 +80,11 @@ module Squared
|
|
68
80
|
@script[:build] = run
|
69
81
|
@script[:dev] = dev
|
70
82
|
@script[:prod] = prod
|
71
|
-
|
72
|
-
@script[:group][:_] = group
|
83
|
+
set_ref
|
73
84
|
end
|
74
85
|
self
|
75
86
|
end
|
76
87
|
|
77
|
-
protected
|
78
|
-
|
79
|
-
def repo?
|
80
|
-
!@manifest_url.nil? && (install? || !!@override)
|
81
|
-
end
|
82
|
-
|
83
|
-
def empty?(dir)
|
84
|
-
dir.empty? || (dir.children.size == 1 && dir.join(dir.children.first).to_s == __FILE__)
|
85
|
-
end
|
86
|
-
|
87
88
|
private
|
88
89
|
|
89
90
|
def __repo__(**kwargs)
|
@@ -115,17 +116,21 @@ module Squared
|
|
115
116
|
end
|
116
117
|
status = lambda do |val, alt = nil|
|
117
118
|
ver = branch || alt
|
118
|
-
|
119
|
+
if ver
|
120
|
+
message(@prefix || '', 'repo', val.sub('{0}', 'opts*=force,rebase,detach,gc,no-update,no-fail'), ver)
|
121
|
+
else
|
122
|
+
'inactive'
|
123
|
+
end
|
119
124
|
end
|
120
125
|
|
121
|
-
namespace 'repo' do |repo|
|
126
|
+
namespace task_name('repo') do |repo|
|
122
127
|
desc status.('all[{0}]')
|
123
128
|
task 'all', [:opts] do |_, args|
|
124
129
|
parse_opts.(args)
|
125
130
|
stage ||= 'all'
|
126
131
|
repo['sync'].invoke
|
127
132
|
@project.select do |_, proj|
|
128
|
-
next unless proj.enabled?
|
133
|
+
next false unless proj.enabled? && proj.ref?(Project::Base.ref)
|
129
134
|
|
130
135
|
proj.depend if proj.depend?
|
131
136
|
proj.build?
|
@@ -144,8 +149,9 @@ module Squared
|
|
144
149
|
|
145
150
|
desc status.('sync[{0}]')
|
146
151
|
task 'sync', [:opts] do |_, args|
|
147
|
-
|
148
|
-
|
152
|
+
unless branch || stage == 'init'
|
153
|
+
raise_error('repo is not initialized', "rake #{task_name('repo:init')}", kind: LoadError)
|
154
|
+
end
|
149
155
|
parse_opts.(args)
|
150
156
|
cmd << "-j#{ENV.fetch('REPO_JOBS', ::Rake::CpuCounter.count)}"
|
151
157
|
cmd << '--fail-fast' if failfast
|
@@ -153,7 +159,7 @@ module Squared
|
|
153
159
|
begin
|
154
160
|
shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
|
155
161
|
rescue StandardError => e
|
156
|
-
emphasize(e, title: "rake stash repo:#{stage || 'sync'}")
|
162
|
+
emphasize(e, title: "rake stash #{task_name("repo:#{stage || 'sync'}")}")
|
157
163
|
raise
|
158
164
|
end
|
159
165
|
end
|
@@ -192,6 +198,14 @@ module Squared
|
|
192
198
|
end
|
193
199
|
end
|
194
200
|
|
201
|
+
def repo?
|
202
|
+
!@manifest_url.nil? && (install? || !!@override)
|
203
|
+
end
|
204
|
+
|
205
|
+
def empty?(dir)
|
206
|
+
dir.empty? || (dir.children.size == 1 && dir.join(dir.children.first).to_s == __FILE__)
|
207
|
+
end
|
208
|
+
|
195
209
|
def install?(dir = root)
|
196
210
|
return true if empty?(dir) || dir.join('.repo').directory?
|
197
211
|
return false unless dir == root && env('REPO_HOME').nil? && !env('REPO_ROOT').nil?
|
@@ -8,18 +8,31 @@ module Squared
|
|
8
8
|
include ::Rake::DSL
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
+
TASK_BASE = %i[build refresh depend outdated doc test copy clean].freeze
|
12
|
+
TASK_ALIAS = {
|
13
|
+
refresh: :build
|
14
|
+
}
|
15
|
+
TASK_KEYS = TASK_BASE.dup
|
16
|
+
TASK_EXTEND = {}
|
17
|
+
private_constant :TASK_BASE, :TASK_ALIAS, :TASK_KEYS, :TASK_EXTEND
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def add(task, obj)
|
21
|
+
TASK_KEYS << task unless TASK_KEYS.include?(task)
|
22
|
+
(TASK_EXTEND[task] ||= []).push(obj)
|
23
|
+
end
|
24
|
+
|
25
|
+
def alias(key, task)
|
26
|
+
TASK_ALIAS[key.to_sym] = task.to_sym
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
11
30
|
attr_reader :sync, :multiple, :parallel
|
12
31
|
|
13
32
|
def_delegators :@data, :[], :each, :each_key, :keys, :fetch, :to_a, :to_s, :inspect, :merge!, :key?
|
14
33
|
|
15
|
-
def initialize(
|
16
|
-
|
17
|
-
@data = {}
|
18
|
-
tasks.each { |key| __set__ key }
|
19
|
-
else
|
20
|
-
@data = tasks.dup
|
21
|
-
end
|
22
|
-
@keys = keys
|
34
|
+
def initialize(workspace)
|
35
|
+
@workspace = workspace
|
23
36
|
@sync = []
|
24
37
|
@multiple = []
|
25
38
|
@parallel = []
|
@@ -28,75 +41,84 @@ module Squared
|
|
28
41
|
parent: {},
|
29
42
|
id: []
|
30
43
|
}
|
44
|
+
@data = {}
|
45
|
+
TASK_KEYS.each { |key| @data[key] = [] }
|
31
46
|
end
|
32
47
|
|
33
48
|
def __set__(key)
|
34
49
|
self[key.to_sym] ||= []
|
35
50
|
end
|
36
51
|
|
37
|
-
def
|
52
|
+
def __populate__(proj)
|
38
53
|
return unless @session
|
39
54
|
|
40
55
|
group, parent, id = @session.values
|
41
|
-
|
56
|
+
ws = proj.workspace
|
42
57
|
each do |key, items|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
next unless workspace.task_include?(proj, key)
|
58
|
+
task = "#{proj.name}:#{key}"
|
59
|
+
unless include?(key) ? proj.has?(key) || ws.task_defined?(key) : ws.task_extend?(proj, key)
|
60
|
+
alt = TASK_ALIAS[key]
|
61
|
+
next unless alt && (task = "#{proj.name}:#{alt}") && self[alt].include?(task)
|
48
62
|
end
|
49
|
-
next unless
|
63
|
+
next unless ws.task_defined?(task)
|
50
64
|
|
51
65
|
if (g = proj.group)
|
52
66
|
id << g
|
53
|
-
(group[:"#{key}:#{g}"] ||= []).push(
|
67
|
+
(group[:"#{key}:#{g}"] ||= []).push(task)
|
54
68
|
else
|
55
|
-
items <<
|
69
|
+
items << task
|
56
70
|
end
|
57
|
-
next unless (b = find_base(proj)) && (name = b.ref.to_s) != g
|
71
|
+
next unless (b = ws.find_base(proj)) && (name = b.ref.to_s) != g
|
58
72
|
|
59
73
|
id << name
|
60
|
-
(parent[:"#{key}:#{name}"] ||= []).push(
|
74
|
+
(parent[:"#{key}:#{name}"] ||= []).push(task)
|
61
75
|
end
|
62
76
|
end
|
63
77
|
|
64
|
-
def
|
65
|
-
thread = kwargs.fetch(:parallel, []).map(&:to_s)
|
78
|
+
def __build__(parallel: [], **)
|
66
79
|
group, parent, id = @session.values
|
67
80
|
merge!(parent) if id.uniq.size > 1
|
68
81
|
merge!(group)
|
69
82
|
each do |key, items|
|
70
83
|
next if items.empty?
|
71
84
|
|
72
|
-
key = key.to_s
|
85
|
+
key = @workspace.task_name(name = key.to_s)
|
86
|
+
val = @workspace.task_name(name, desc: true)
|
73
87
|
if items.size > 1
|
74
|
-
multiple << key
|
75
|
-
if
|
76
|
-
desc "#{
|
88
|
+
@multiple << key
|
89
|
+
if parallel.include?(name) || ((ns = @workspace.task_namespace(name)) && parallel.include?(ns))
|
90
|
+
desc "#{val} (thread)"
|
77
91
|
multitask key => items
|
78
|
-
parallel << key
|
92
|
+
@parallel << key
|
79
93
|
|
80
|
-
desc "#{
|
81
|
-
task "#{key}:sync"
|
82
|
-
sync << "#{key}:sync"
|
83
|
-
multiple << "#{key}:sync"
|
94
|
+
desc "#{val} (sync)"
|
95
|
+
task "#{key}:sync" => items
|
96
|
+
@sync << "#{key}:sync"
|
84
97
|
next
|
85
98
|
end
|
86
99
|
end
|
87
100
|
|
88
|
-
desc
|
101
|
+
desc val
|
89
102
|
task key => items
|
90
103
|
end
|
104
|
+
TASK_ALIAS.each_key do |key|
|
105
|
+
suf = ":#{key}"
|
106
|
+
self[key].clear unless self[key].any? { |val| val.end_with?(suf) }
|
107
|
+
end
|
108
|
+
@multiple += sync
|
91
109
|
@session = nil
|
92
110
|
end
|
93
111
|
|
94
|
-
def
|
95
|
-
self[key]
|
112
|
+
def some?(key)
|
113
|
+
!key.nil? && key?(key = key.to_sym) && !self[key].empty?
|
96
114
|
end
|
97
115
|
|
98
|
-
def
|
99
|
-
|
116
|
+
def include?(key)
|
117
|
+
TASK_BASE.include?(key)
|
118
|
+
end
|
119
|
+
|
120
|
+
def extend?(obj, key)
|
121
|
+
TASK_EXTEND.fetch(key, []).any? { |kind| obj.is_a?(kind) && obj.ref?(kind.ref) }
|
100
122
|
end
|
101
123
|
|
102
124
|
def multiple?(val = nil)
|
@@ -111,12 +133,14 @@ module Squared
|
|
111
133
|
already_invoked?(parallel, val)
|
112
134
|
end
|
113
135
|
|
114
|
-
def respond_to_missing?(key, *)
|
115
|
-
key?(key)
|
116
|
-
end
|
117
|
-
|
118
136
|
private
|
119
137
|
|
138
|
+
def method_missing(key, *)
|
139
|
+
raise NoMethodError, key unless key?(key)
|
140
|
+
|
141
|
+
self[key]
|
142
|
+
end
|
143
|
+
|
120
144
|
def already_invoked?(list, val)
|
121
145
|
return list.include?(val) && Common::Task.invoked?(val) if val
|
122
146
|
|
data/lib/squared/workspace.rb
CHANGED
@@ -12,7 +12,7 @@ module Squared
|
|
12
12
|
if id.is_a?(::Symbol)
|
13
13
|
project id
|
14
14
|
else
|
15
|
-
|
15
|
+
id = dirpath(id) if id.is_a?(::String)
|
16
16
|
__get__(:project).find { |_, val| val.path.to_s == id.to_s }
|
17
17
|
end
|
18
18
|
end
|
@@ -26,6 +26,12 @@ module Squared
|
|
26
26
|
raise NoMethodError, message('project is not initialized', hint: name)
|
27
27
|
end
|
28
28
|
|
29
|
+
def dirpath(val, absolute: true)
|
30
|
+
Pathname.new(val).realdirpath
|
31
|
+
rescue StandardError
|
32
|
+
absolute ? Pathname.pwd.join(val) : Pathname.new(val)
|
33
|
+
end
|
34
|
+
|
29
35
|
def project?(name)
|
30
36
|
!!project(name)&.enabled?
|
31
37
|
end
|
@@ -39,6 +45,6 @@ module Squared
|
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
|
-
require_relative 'workspace/application'
|
43
48
|
require_relative 'workspace/series'
|
49
|
+
require_relative 'workspace/application'
|
44
50
|
require_relative 'workspace/project'
|
data/squared.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rexml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Rake task generator for managing multi-language workspaces.
|
42
56
|
email:
|
43
57
|
- anpham6@gmail.com
|