1
|
|
|
'use strict' |
2
|
|
|
|
3
|
|
|
const path = require('path') |
4
|
|
|
const eol = require('eol') |
5
|
|
|
const fs = require('fs') |
6
|
|
|
|
7
|
|
|
const removeArrayItem = function (arr, itemToRemove) { |
8
|
|
|
return arr.filter(function (item) { |
9
|
|
|
return item !== itemToRemove |
10
|
|
|
}) |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
module.exports = function () { |
14
|
|
|
/* |
15
|
|
|
* Version 1.0 to 1.1 |
16
|
|
|
* |
17
|
|
|
* move .scholica -> .inc/containers/default.json |
18
|
|
|
* move .scholica.dev -> .inc/containers/beta.json |
19
|
|
|
* move .phpstorm.meta.php -> .inc/meta/.phpstorm.meta.php |
20
|
|
|
* file .inc/version |
21
|
|
|
* edit .gitignore |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
if (!fs.existsSync('.inc')) { |
25
|
|
|
fs.mkdirSync('.inc') |
26
|
|
|
|
27
|
|
|
fs.mkdirSync(path.join('.inc', 'containers')) |
28
|
|
|
if (fs.existsSync('.scholica')) { |
29
|
|
|
fs.renameSync('.scholica', path.join('.inc', 'containers', 'default.json')) |
30
|
|
|
} |
31
|
|
|
if (fs.existsSync('.scholica.beta')) { |
32
|
|
|
fs.renameSync('.scholica.beta', path.join('.inc', 'containers', 'beta.json')) |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
fs.mkdirSync(path.join('.inc', 'meta')) |
36
|
|
|
if (fs.existsSync('.phpstorm.meta.php')) { |
37
|
|
|
fs.renameSync('.phpstorm.meta.php', path.join('.inc', 'meta', '.phpstorm.meta.php')) |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if (fs.existsSync('.gitignore')) { |
41
|
|
|
var lines = fs.readFileSync('.gitignore', 'utf8') |
42
|
|
|
lines = eol.split(lines) |
43
|
|
|
lines = removeArrayItem(lines, '/.scholica') |
44
|
|
|
lines = removeArrayItem(lines, '/.scholica.beta') |
45
|
|
|
lines = removeArrayItem(lines, '.scholica') |
46
|
|
|
lines = removeArrayItem(lines, '.scholica.beta') |
47
|
|
|
lines = removeArrayItem(lines, '.phpstorm.meta.php') |
48
|
|
|
lines = removeArrayItem(lines, '.container') |
49
|
|
|
lines = removeArrayItem(lines, '.container.dev') |
50
|
|
|
if (!lines[lines.length - 1].length) { |
51
|
|
|
lines[lines.length - 1] = '.inc' |
52
|
|
|
} else { |
53
|
|
|
lines.push('.inc') |
54
|
|
|
} |
55
|
|
|
lines.push('') |
56
|
|
|
fs.writeFileSync('.gitignore', lines.join(eol.auto), 'utf8') |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
fs.writeFileSync(path.join('.inc', 'version'), '11', 'utf8') |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|