dsu 3.0.0.alpha.12 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +19 -16
- data/lib/dsu/cli.rb +2 -1
- data/lib/dsu/crud/json_file.rb +5 -0
- data/lib/dsu/migration/base_service.rb +118 -0
- data/lib/dsu/migration/migrator.rb +24 -0
- data/lib/dsu/migration/raw_helpers/color_theme_hash.rb +13 -0
- data/lib/dsu/migration/raw_helpers/configuration_hash.rb +15 -0
- data/lib/dsu/migration/raw_helpers/entry_group_hash.rb +13 -0
- data/lib/dsu/migration/raw_json_file.rb +15 -0
- data/lib/dsu/migration/raw_json_files.rb +56 -0
- data/lib/dsu/migration/v20230613121411/service.rb +94 -0
- data/lib/dsu/migration/v20240210161248/service.rb +148 -0
- data/lib/dsu/models/color_theme.rb +2 -0
- data/lib/dsu/models/configuration.rb +6 -0
- data/lib/dsu/models/project.rb +2 -2
- data/lib/dsu/presenters/project/defaultable.rb +15 -0
- data/lib/dsu/presenters/project/use_by_number_presenter.rb +4 -0
- data/lib/dsu/presenters/project/use_presenter.rb +4 -0
- data/lib/dsu/subcommands/project.rb +3 -6
- data/lib/dsu/support/fileable.rb +11 -7
- data/lib/dsu/support/project_file_system.rb +2 -5
- data/lib/dsu/version.rb +2 -2
- data/lib/dsu/views/project/list.rb +4 -4
- data/lib/dsu.rb +8 -13
- data/lib/locales/en/commands.yml +4 -0
- data/lib/locales/en/miscellaneous.yml +1 -2
- data/lib/locales/en/subcommands.yml +21 -11
- data/lib/seed_data/20230613121411/dsu/migration_version.json +3 -0
- data/lib/seed_data/{themes → 20230613121411/dsu/themes}/light.json +2 -2
- data/lib/seed_data/20240210161248/dsu/current_project.json +4 -0
- data/lib/seed_data/20240210161248/dsu/migration_version.json +3 -0
- data/lib/seed_data/20240210161248/dsu/projects/default/project.json +5 -0
- data/lib/seed_data/20240210161248/dsu/themes/cherry.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/christmas.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/default.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/lemon.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/light.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/matrix.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/whiteout.json +79 -0
- metadata +32 -12
- data/lib/dsu/migration/factory.rb +0 -26
- data/lib/dsu/migration/service.rb +0 -196
- data/lib/dsu/migration/service_20230613121411.rb +0 -178
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/cherry.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/christmas.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/default.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/lemon.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/matrix.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/whiteout.json +0 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
{
|
2
|
+
"version": 20240210161248,
|
3
|
+
"description": "Lemon color theme",
|
4
|
+
"help": {
|
5
|
+
"color": "yellow",
|
6
|
+
"mode": "default",
|
7
|
+
"background": "default"
|
8
|
+
},
|
9
|
+
"dsu_header": {
|
10
|
+
"color": "white",
|
11
|
+
"mode": "bold",
|
12
|
+
"background": "yellow"
|
13
|
+
},
|
14
|
+
"dsu_footer": {
|
15
|
+
"color": "yellow",
|
16
|
+
"mode": "default",
|
17
|
+
"background": "default"
|
18
|
+
},
|
19
|
+
"header": {
|
20
|
+
"color": "yellow",
|
21
|
+
"mode": "bold",
|
22
|
+
"background": "default"
|
23
|
+
},
|
24
|
+
"subheader": {
|
25
|
+
"color": "yellow",
|
26
|
+
"mode": "underline",
|
27
|
+
"background": "default"
|
28
|
+
},
|
29
|
+
"body": {
|
30
|
+
"color": "yellow",
|
31
|
+
"mode": "default",
|
32
|
+
"background": "default"
|
33
|
+
},
|
34
|
+
"footer": {
|
35
|
+
"color": "light_yellow",
|
36
|
+
"mode": "default",
|
37
|
+
"background": "default"
|
38
|
+
},
|
39
|
+
"date": {
|
40
|
+
"color": "yellow",
|
41
|
+
"mode": "bold",
|
42
|
+
"background": "default"
|
43
|
+
},
|
44
|
+
"index": {
|
45
|
+
"color": "light_yellow",
|
46
|
+
"mode": "default",
|
47
|
+
"background": "default"
|
48
|
+
},
|
49
|
+
"info": {
|
50
|
+
"color": "yellow",
|
51
|
+
"mode": "default",
|
52
|
+
"background": "default"
|
53
|
+
},
|
54
|
+
"success": {
|
55
|
+
"color": "green",
|
56
|
+
"mode": "default",
|
57
|
+
"background": "default"
|
58
|
+
},
|
59
|
+
"warning": {
|
60
|
+
"color": "yellow",
|
61
|
+
"mode": "default",
|
62
|
+
"background": "default"
|
63
|
+
},
|
64
|
+
"error": {
|
65
|
+
"color": "light_yellow",
|
66
|
+
"mode": "default",
|
67
|
+
"background": "red"
|
68
|
+
},
|
69
|
+
"prompt": {
|
70
|
+
"color": "yellow",
|
71
|
+
"mode": "bold",
|
72
|
+
"background": "default"
|
73
|
+
},
|
74
|
+
"prompt_options": {
|
75
|
+
"color": "white",
|
76
|
+
"mode": "bold",
|
77
|
+
"background": "default"
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
{
|
2
|
+
"version": 20240210161248,
|
3
|
+
"description": "Theme for Light backgrounds",
|
4
|
+
"help": {
|
5
|
+
"color": "default",
|
6
|
+
"mode": "default",
|
7
|
+
"background": "default"
|
8
|
+
},
|
9
|
+
"dsu_header": {
|
10
|
+
"color": "white",
|
11
|
+
"mode": "bold",
|
12
|
+
"background": "black"
|
13
|
+
},
|
14
|
+
"dsu_footer": {
|
15
|
+
"color": "default",
|
16
|
+
"mode": "default",
|
17
|
+
"background": "default"
|
18
|
+
},
|
19
|
+
"header": {
|
20
|
+
"color": "default",
|
21
|
+
"mode": "bold",
|
22
|
+
"background": "default"
|
23
|
+
},
|
24
|
+
"subheader": {
|
25
|
+
"color": "default",
|
26
|
+
"mode": "underline",
|
27
|
+
"background": "default"
|
28
|
+
},
|
29
|
+
"body": {
|
30
|
+
"color": "default",
|
31
|
+
"mode": "default",
|
32
|
+
"background": "default"
|
33
|
+
},
|
34
|
+
"footer": {
|
35
|
+
"color": "default",
|
36
|
+
"mode": "default",
|
37
|
+
"background": "default"
|
38
|
+
},
|
39
|
+
"date": {
|
40
|
+
"color": "default",
|
41
|
+
"mode": "bold",
|
42
|
+
"background": "default"
|
43
|
+
},
|
44
|
+
"index": {
|
45
|
+
"color": "default",
|
46
|
+
"mode": "italic",
|
47
|
+
"background": "default"
|
48
|
+
},
|
49
|
+
"info": {
|
50
|
+
"color": "white",
|
51
|
+
"mode": "bold",
|
52
|
+
"background": "blue"
|
53
|
+
},
|
54
|
+
"success": {
|
55
|
+
"color": "white",
|
56
|
+
"mode": "bold",
|
57
|
+
"background": "green"
|
58
|
+
},
|
59
|
+
"warning": {
|
60
|
+
"color": "default",
|
61
|
+
"mode": "bold",
|
62
|
+
"background": "yellow"
|
63
|
+
},
|
64
|
+
"error": {
|
65
|
+
"color": "light_yellow",
|
66
|
+
"mode": "default",
|
67
|
+
"background": "red"
|
68
|
+
},
|
69
|
+
"prompt": {
|
70
|
+
"color": "default",
|
71
|
+
"mode": "bold",
|
72
|
+
"background": "default"
|
73
|
+
},
|
74
|
+
"prompt_options": {
|
75
|
+
"color": "default",
|
76
|
+
"mode": "bold",
|
77
|
+
"background": "default"
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
{
|
2
|
+
"version": 20240210161248,
|
3
|
+
"description": "Matrix color theme",
|
4
|
+
"help": {
|
5
|
+
"color": "green",
|
6
|
+
"mode": "default",
|
7
|
+
"background": "default"
|
8
|
+
},
|
9
|
+
"dsu_header": {
|
10
|
+
"color": "white",
|
11
|
+
"mode": "bold",
|
12
|
+
"background": "green"
|
13
|
+
},
|
14
|
+
"dsu_footer": {
|
15
|
+
"color": "green",
|
16
|
+
"mode": "default",
|
17
|
+
"background": "default"
|
18
|
+
},
|
19
|
+
"header": {
|
20
|
+
"color": "green",
|
21
|
+
"mode": "bold",
|
22
|
+
"background": "default"
|
23
|
+
},
|
24
|
+
"subheader": {
|
25
|
+
"color": "green",
|
26
|
+
"mode": "underline",
|
27
|
+
"background": "default"
|
28
|
+
},
|
29
|
+
"body": {
|
30
|
+
"color": "green",
|
31
|
+
"mode": "default",
|
32
|
+
"background": "default"
|
33
|
+
},
|
34
|
+
"footer": {
|
35
|
+
"color": "light_green",
|
36
|
+
"mode": "default",
|
37
|
+
"background": "default"
|
38
|
+
},
|
39
|
+
"date": {
|
40
|
+
"color": "green",
|
41
|
+
"mode": "bold",
|
42
|
+
"background": "default"
|
43
|
+
},
|
44
|
+
"index": {
|
45
|
+
"color": "light_green",
|
46
|
+
"mode": "default",
|
47
|
+
"background": "default"
|
48
|
+
},
|
49
|
+
"info": {
|
50
|
+
"color": "green",
|
51
|
+
"mode": "default",
|
52
|
+
"background": "default"
|
53
|
+
},
|
54
|
+
"success": {
|
55
|
+
"color": "green",
|
56
|
+
"mode": "default",
|
57
|
+
"background": "default"
|
58
|
+
},
|
59
|
+
"warning": {
|
60
|
+
"color": "yellow",
|
61
|
+
"mode": "default",
|
62
|
+
"background": "default"
|
63
|
+
},
|
64
|
+
"error": {
|
65
|
+
"color": "light_yellow",
|
66
|
+
"mode": "default",
|
67
|
+
"background": "red"
|
68
|
+
},
|
69
|
+
"prompt": {
|
70
|
+
"color": "green",
|
71
|
+
"mode": "bold",
|
72
|
+
"background": "default"
|
73
|
+
},
|
74
|
+
"prompt_options": {
|
75
|
+
"color": "white",
|
76
|
+
"mode": "bold",
|
77
|
+
"background": "default"
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
{
|
2
|
+
"version": 20240210161248,
|
3
|
+
"description": "Whiteout color theme",
|
4
|
+
"help": {
|
5
|
+
"color": "white",
|
6
|
+
"mode": "default",
|
7
|
+
"background": "default"
|
8
|
+
},
|
9
|
+
"dsu_header": {
|
10
|
+
"color": "white",
|
11
|
+
"mode": "bold",
|
12
|
+
"background": "white"
|
13
|
+
},
|
14
|
+
"dsu_footer": {
|
15
|
+
"color": "white",
|
16
|
+
"mode": "default",
|
17
|
+
"background": "default"
|
18
|
+
},
|
19
|
+
"header": {
|
20
|
+
"color": "white",
|
21
|
+
"mode": "bold",
|
22
|
+
"background": "default"
|
23
|
+
},
|
24
|
+
"subheader": {
|
25
|
+
"color": "white",
|
26
|
+
"mode": "underline",
|
27
|
+
"background": "default"
|
28
|
+
},
|
29
|
+
"body": {
|
30
|
+
"color": "white",
|
31
|
+
"mode": "default",
|
32
|
+
"background": "default"
|
33
|
+
},
|
34
|
+
"footer": {
|
35
|
+
"color": "light_white",
|
36
|
+
"mode": "default",
|
37
|
+
"background": "default"
|
38
|
+
},
|
39
|
+
"date": {
|
40
|
+
"color": "white",
|
41
|
+
"mode": "bold",
|
42
|
+
"background": "default"
|
43
|
+
},
|
44
|
+
"index": {
|
45
|
+
"color": "light_white",
|
46
|
+
"mode": "default",
|
47
|
+
"background": "default"
|
48
|
+
},
|
49
|
+
"info": {
|
50
|
+
"color": "white",
|
51
|
+
"mode": "default",
|
52
|
+
"background": "default"
|
53
|
+
},
|
54
|
+
"success": {
|
55
|
+
"color": "green",
|
56
|
+
"mode": "default",
|
57
|
+
"background": "default"
|
58
|
+
},
|
59
|
+
"warning": {
|
60
|
+
"color": "yellow",
|
61
|
+
"mode": "default",
|
62
|
+
"background": "default"
|
63
|
+
},
|
64
|
+
"error": {
|
65
|
+
"color": "light_yellow",
|
66
|
+
"mode": "default",
|
67
|
+
"background": "red"
|
68
|
+
},
|
69
|
+
"prompt": {
|
70
|
+
"color": "white",
|
71
|
+
"mode": "bold",
|
72
|
+
"background": "default"
|
73
|
+
},
|
74
|
+
"prompt_options": {
|
75
|
+
"color": "white",
|
76
|
+
"mode": "bold",
|
77
|
+
"background": "default"
|
78
|
+
}
|
79
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene M. Angelo, Jr.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -169,9 +169,15 @@ files:
|
|
169
169
|
- lib/dsu/command_services/add_entry_service.rb
|
170
170
|
- lib/dsu/crud/json_file.rb
|
171
171
|
- lib/dsu/env.rb
|
172
|
-
- lib/dsu/migration/
|
173
|
-
- lib/dsu/migration/
|
174
|
-
- lib/dsu/migration/
|
172
|
+
- lib/dsu/migration/base_service.rb
|
173
|
+
- lib/dsu/migration/migrator.rb
|
174
|
+
- lib/dsu/migration/raw_helpers/color_theme_hash.rb
|
175
|
+
- lib/dsu/migration/raw_helpers/configuration_hash.rb
|
176
|
+
- lib/dsu/migration/raw_helpers/entry_group_hash.rb
|
177
|
+
- lib/dsu/migration/raw_json_file.rb
|
178
|
+
- lib/dsu/migration/raw_json_files.rb
|
179
|
+
- lib/dsu/migration/v20230613121411/service.rb
|
180
|
+
- lib/dsu/migration/v20240210161248/service.rb
|
175
181
|
- lib/dsu/migration/version.rb
|
176
182
|
- lib/dsu/models/color_theme.rb
|
177
183
|
- lib/dsu/models/configuration.rb
|
@@ -197,6 +203,7 @@ files:
|
|
197
203
|
- lib/dsu/presenters/import/import_entry.rb
|
198
204
|
- lib/dsu/presenters/import/import_file.rb
|
199
205
|
- lib/dsu/presenters/project/create_presenter.rb
|
206
|
+
- lib/dsu/presenters/project/defaultable.rb
|
200
207
|
- lib/dsu/presenters/project/delete_by_number_presenter.rb
|
201
208
|
- lib/dsu/presenters/project/delete_presenter.rb
|
202
209
|
- lib/dsu/presenters/project/list_presenter.rb
|
@@ -292,13 +299,24 @@ files:
|
|
292
299
|
- lib/locales/en/presenters.yml
|
293
300
|
- lib/locales/en/services.yml
|
294
301
|
- lib/locales/en/subcommands.yml
|
295
|
-
- lib/seed_data/
|
296
|
-
- lib/seed_data/themes/
|
297
|
-
- lib/seed_data/themes/
|
298
|
-
- lib/seed_data/themes/
|
299
|
-
- lib/seed_data/themes/
|
300
|
-
- lib/seed_data/themes/
|
301
|
-
- lib/seed_data/themes/
|
302
|
+
- lib/seed_data/20230613121411/dsu/migration_version.json
|
303
|
+
- lib/seed_data/20230613121411/dsu/themes/cherry.json
|
304
|
+
- lib/seed_data/20230613121411/dsu/themes/christmas.json
|
305
|
+
- lib/seed_data/20230613121411/dsu/themes/default.json
|
306
|
+
- lib/seed_data/20230613121411/dsu/themes/lemon.json
|
307
|
+
- lib/seed_data/20230613121411/dsu/themes/light.json
|
308
|
+
- lib/seed_data/20230613121411/dsu/themes/matrix.json
|
309
|
+
- lib/seed_data/20230613121411/dsu/themes/whiteout.json
|
310
|
+
- lib/seed_data/20240210161248/dsu/current_project.json
|
311
|
+
- lib/seed_data/20240210161248/dsu/migration_version.json
|
312
|
+
- lib/seed_data/20240210161248/dsu/projects/default/project.json
|
313
|
+
- lib/seed_data/20240210161248/dsu/themes/cherry.json
|
314
|
+
- lib/seed_data/20240210161248/dsu/themes/christmas.json
|
315
|
+
- lib/seed_data/20240210161248/dsu/themes/default.json
|
316
|
+
- lib/seed_data/20240210161248/dsu/themes/lemon.json
|
317
|
+
- lib/seed_data/20240210161248/dsu/themes/light.json
|
318
|
+
- lib/seed_data/20240210161248/dsu/themes/matrix.json
|
319
|
+
- lib/seed_data/20240210161248/dsu/themes/whiteout.json
|
302
320
|
- project.bak
|
303
321
|
- sig/dsu.rbs
|
304
322
|
homepage: https://github.com/gangelo/dsu
|
@@ -340,6 +358,8 @@ post_install_message: |
|
|
340
358
|
Thank you!
|
341
359
|
|
342
360
|
<3 Gene
|
361
|
+
|
362
|
+
dsu now uses "Projects"! Run `dsu help project` to get started.
|
343
363
|
rdoc_options: []
|
344
364
|
require_paths:
|
345
365
|
- lib
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../models/migration_version'
|
4
|
-
require_relative 'service_20230613121411'
|
5
|
-
require_relative 'version'
|
6
|
-
|
7
|
-
module Dsu
|
8
|
-
module Migration
|
9
|
-
class Factory
|
10
|
-
class << self
|
11
|
-
def migrate_if!(options: {})
|
12
|
-
version = options.fetch(:version, migration_version)
|
13
|
-
if version == 20230613121411 # rubocop:disable Style/NumericLiterals
|
14
|
-
Service20230613121411.new(options: options).migrate!
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def migration_version
|
21
|
-
@migration_version ||= Models::MigrationVersion.new.version
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,196 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
require 'json'
|
5
|
-
require_relative '../migration/version'
|
6
|
-
require_relative '../models/configuration'
|
7
|
-
require_relative '../models/migration_version'
|
8
|
-
require_relative '../support/fileable'
|
9
|
-
|
10
|
-
module Dsu
|
11
|
-
module Migration
|
12
|
-
MIGRATION_VERSION_REGEX = /(\A\d+)/
|
13
|
-
|
14
|
-
class Service
|
15
|
-
include Support::Fileable
|
16
|
-
|
17
|
-
def initialize(options: {})
|
18
|
-
@options = options || {}
|
19
|
-
@migration_version = Models::MigrationVersion.new(options: options)
|
20
|
-
@start_migration_version = @migration_version.version
|
21
|
-
end
|
22
|
-
|
23
|
-
def call
|
24
|
-
unless self.class.run_migrations?
|
25
|
-
puts 'Nothing to do.'
|
26
|
-
return
|
27
|
-
end
|
28
|
-
|
29
|
-
run_migrations!
|
30
|
-
end
|
31
|
-
|
32
|
-
class << self
|
33
|
-
def run_migrations?
|
34
|
-
Models::MigrationVersion.new.version < 20230613121411 # rubocop:disable Style/NumericLiterals
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
attr_reader :migration_version, :options, :start_migration_version
|
41
|
-
|
42
|
-
def run_migrations!
|
43
|
-
puts "dsu version: #{Dsu::VERSION}"
|
44
|
-
puts
|
45
|
-
|
46
|
-
puts 'Running migrations...'
|
47
|
-
puts
|
48
|
-
|
49
|
-
puts "Current migration version: #{start_migration_version}"
|
50
|
-
puts "Migrating to version: #{Dsu::Migration::VERSION}"
|
51
|
-
puts
|
52
|
-
|
53
|
-
backup!
|
54
|
-
cleanup!
|
55
|
-
migrate!
|
56
|
-
|
57
|
-
new_migration_version = Models::MigrationVersion.new(version: Dsu::Migration::VERSION).tap(&:save!).version
|
58
|
-
|
59
|
-
puts "Migration version after migration is: #{new_migration_version}"
|
60
|
-
puts 'Migration completed successfully.'
|
61
|
-
rescue StandardError => e
|
62
|
-
warn "Migration completed with errors: #{e.message}"
|
63
|
-
end
|
64
|
-
|
65
|
-
def backup!
|
66
|
-
backup_config!
|
67
|
-
puts
|
68
|
-
|
69
|
-
backup_entry_groups!
|
70
|
-
puts
|
71
|
-
|
72
|
-
backup_themes!
|
73
|
-
puts
|
74
|
-
end
|
75
|
-
|
76
|
-
def backup_config!
|
77
|
-
puts 'Backing up config...'
|
78
|
-
if File.exist?(config_path)
|
79
|
-
backup_path = File.join(current_backup_folder, config_file_name)
|
80
|
-
puts "Backing up #{config_path} to #{backup_path}..."
|
81
|
-
FileUtils.cp(config_path, backup_path)
|
82
|
-
else
|
83
|
-
puts 'No config to backup.'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def backup_entry_groups!
|
88
|
-
puts 'Backing up entry groups...'
|
89
|
-
if Dir.exist?(entries_folder)
|
90
|
-
backup_folder = File.join(current_backup_folder, File.basename(entries_folder))
|
91
|
-
puts "Backing up #{entries_folder} to #{backup_folder}..."
|
92
|
-
FileUtils.mkdir_p(backup_folder)
|
93
|
-
FileUtils.cp_r("#{entries_folder}/.", backup_folder)
|
94
|
-
else
|
95
|
-
puts 'No entries to backup.'
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def backup_themes!
|
100
|
-
puts 'Backing up themes...'
|
101
|
-
if Dir.exist?(themes_folder)
|
102
|
-
backup_folder = File.join(current_backup_folder, File.basename(themes_folder))
|
103
|
-
puts "Backing up #{themes_folder} to #{backup_folder}..."
|
104
|
-
FileUtils.mkdir_p(backup_folder)
|
105
|
-
FileUtils.cp_r("#{themes_folder}/.", backup_folder)
|
106
|
-
else
|
107
|
-
puts 'No entries to backup.'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def before_migration_version
|
112
|
-
@before_migration_version ||= migration_version_instance.version
|
113
|
-
end
|
114
|
-
|
115
|
-
def cleanup!
|
116
|
-
puts 'Cleaning up old config file...'
|
117
|
-
File.delete(config_path) if File.file?(config_path)
|
118
|
-
puts 'Done.'
|
119
|
-
puts
|
120
|
-
|
121
|
-
puts 'Cleaning up old entries...'
|
122
|
-
entry_files = Dir.glob(File.join(entries_folder, '*'))
|
123
|
-
entry_files.each do |entry_file|
|
124
|
-
File.delete(entry_file) if File.file?(entry_file)
|
125
|
-
end
|
126
|
-
puts 'Done.'
|
127
|
-
puts
|
128
|
-
|
129
|
-
puts 'Cleaning up old themes...'
|
130
|
-
theme_files = Dir.glob(File.join(themes_folder, '*'))
|
131
|
-
theme_files.each do |theme_file|
|
132
|
-
File.delete(theme_file) if File.file?(theme_file)
|
133
|
-
end
|
134
|
-
puts 'Done.'
|
135
|
-
puts
|
136
|
-
end
|
137
|
-
|
138
|
-
def create_backup_folder!
|
139
|
-
FileUtils.mkdir_p(backup_folder(version: current_migration_version))
|
140
|
-
end
|
141
|
-
|
142
|
-
def current_backup_folder
|
143
|
-
@current_backup_folder ||= begin
|
144
|
-
create_backup_folder!
|
145
|
-
backup_folder(version: current_migration_version)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def current_migration_version
|
150
|
-
migration_version_instance.version
|
151
|
-
end
|
152
|
-
|
153
|
-
# Migrate
|
154
|
-
|
155
|
-
def migrate!
|
156
|
-
FileUtils.mkdir_p(dsu_folder)
|
157
|
-
FileUtils.mkdir_p(themes_folder)
|
158
|
-
FileUtils.mkdir_p(entries_folder)
|
159
|
-
|
160
|
-
migrate_themes!
|
161
|
-
migrate_config!
|
162
|
-
migrate_entry_groups!
|
163
|
-
end
|
164
|
-
|
165
|
-
def migrate_config!
|
166
|
-
puts 'Migrating config...'
|
167
|
-
Models::Configuration.new.save!
|
168
|
-
puts 'Done.'
|
169
|
-
end
|
170
|
-
|
171
|
-
def migrate_entry_groups!
|
172
|
-
puts 'Migrating entry groups...'
|
173
|
-
# source_folder = File.join(seed_data_folder, 'entries')
|
174
|
-
# puts "Copying entries from #{source_folder} to #{entries_folder}..."
|
175
|
-
# FileUtils.cp_r("#{source_folder}/.", entries_folder)
|
176
|
-
# puts 'Done.'
|
177
|
-
description = "Migrated DSU to version #{Dsu::Migration::VERSION}"
|
178
|
-
entry = Models::Entry.new(description: description)
|
179
|
-
Models::EntryGroup.new(time: Time.now, entries: [entry]).save!
|
180
|
-
puts 'Done.'
|
181
|
-
end
|
182
|
-
|
183
|
-
def migrate_themes!
|
184
|
-
puts 'Migrating themes...'
|
185
|
-
source_folder = File.join(seed_data_folder, 'themes')
|
186
|
-
puts "Copying themes from #{source_folder} to #{themes_folder}..."
|
187
|
-
FileUtils.cp_r("#{source_folder}/.", themes_folder)
|
188
|
-
puts 'Done.'
|
189
|
-
end
|
190
|
-
|
191
|
-
def migration_version_instance
|
192
|
-
@migration_version_instance ||= Models::MigrationVersion.new
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|