@h3ravel/arquebus 0.3.0 → 0.3.2
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.
- package/README.md +1 -1
- package/bin/index.cjs +4419 -1
- package/bin/index.d.cts +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.js +4384 -1
- package/dist/browser/index.cjs +1269 -1
- package/dist/browser/index.d.cts +1222 -1202
- package/dist/browser/index.d.ts +1222 -1202
- package/dist/browser/index.js +1217 -1
- package/dist/index.cjs +4181 -1
- package/dist/index.d.cts +1306 -1280
- package/dist/index.d.ts +1306 -1280
- package/dist/index.js +4116 -1
- package/dist/migrations/chunk-PECeCxCb.js +15 -0
- package/dist/migrations/index.cjs +4064 -1
- package/dist/migrations/index.d.cts +1250 -1243
- package/dist/migrations/index.d.ts +1247 -1243
- package/dist/migrations/index.js +3994 -1
- package/package.json +3 -3
- package/bin/cli.cjs +0 -4942
- package/bin/cli.d.cts +0 -18
- package/bin/cli.d.ts +0 -18
- package/bin/cli.js +0 -4907
- package/bin/utils.js +0 -141
- /package/{bin → dist}/migrations/stubs/migration-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration-ts.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.create-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.create-ts.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.update-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.update-ts.stub +0 -0
- /package/{bin → dist}/stubs/arquebus.config-js.stub +0 -0
- /package/{bin → dist}/stubs/arquebus.config-ts.stub +0 -0
- /package/{bin → dist}/stubs/model-js.stub +0 -0
- /package/{bin → dist}/stubs/model-ts.stub +0 -0
package/bin/utils.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import * as color from 'colorette'
|
|
2
|
-
|
|
3
|
-
import escalade from 'escalade/sync'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import resolveFrom from 'resolve-from'
|
|
6
|
-
|
|
7
|
-
function success (text) {
|
|
8
|
-
console.log(text)
|
|
9
|
-
process.exit(0)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function exit (text) {
|
|
13
|
-
if (text instanceof Error) {
|
|
14
|
-
if (text.message) {
|
|
15
|
-
console.error(color.red(text.message))
|
|
16
|
-
}
|
|
17
|
-
console.error(color.red(`${text.detail ? `${text.detail}\n` : ''}${text.stack}`))
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
console.error(color.red(text))
|
|
21
|
-
}
|
|
22
|
-
process.exit(1)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function twoColumnDetail (name, value) {
|
|
26
|
-
const regex = /\x1b\[\d+m/g
|
|
27
|
-
const width = Math.min(process.stdout.columns, 100)
|
|
28
|
-
const dots = Math.max(width - name.replace(regex, '').length - value.replace(regex, '').length - 10, 0)
|
|
29
|
-
return console.log(name, color.gray('.'.repeat(dots)), value)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function findUpConfig (cwd, name, extensions) {
|
|
33
|
-
return escalade(cwd, (dir, names) => {
|
|
34
|
-
for (const ext of extensions) {
|
|
35
|
-
const filename = `${name}.${ext}`
|
|
36
|
-
if (names.includes(filename)) {
|
|
37
|
-
return filename
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return false
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function findUpModulePath (cwd, packageName) {
|
|
45
|
-
const modulePackagePath = escalade(cwd, (dir, names) => {
|
|
46
|
-
if (names.includes('package.json')) {
|
|
47
|
-
return 'package.json'
|
|
48
|
-
}
|
|
49
|
-
return false
|
|
50
|
-
})
|
|
51
|
-
try {
|
|
52
|
-
if (modulePackage.name === packageName) {
|
|
53
|
-
return path.join(path.dirname(modulePackagePath), modulePackage.main || 'index.js')
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
/* empty */
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function findModulePkg (moduleId, options = {}) {
|
|
62
|
-
const parts = moduleId.replace(/\\/g, '/').split('/')
|
|
63
|
-
let packageName = ''
|
|
64
|
-
// Handle scoped package name
|
|
65
|
-
if (parts.length > 0 && parts[0][0] === '@') {
|
|
66
|
-
packageName += parts.shift() + '/'
|
|
67
|
-
}
|
|
68
|
-
packageName += parts.shift()
|
|
69
|
-
const packageJson = path.join(packageName, 'package.json')
|
|
70
|
-
const resolved = resolveFrom.silent(options.cwd || process.cwd(), packageJson)
|
|
71
|
-
if (!resolved) {
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
return path.join(path.dirname(resolved), parts.join('/'))
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const join = path.join
|
|
78
|
-
|
|
79
|
-
async function getMigrationPaths (cwd, migrator, defaultPath, path) {
|
|
80
|
-
if (path) {
|
|
81
|
-
return [join(cwd, path)]
|
|
82
|
-
}
|
|
83
|
-
return [
|
|
84
|
-
...migrator.getPaths(),
|
|
85
|
-
join(cwd, defaultPath),
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function localModuleCheck (env) {
|
|
90
|
-
if (!env.modulePath) {
|
|
91
|
-
console.log(color.red('No local arquebus install found.'))
|
|
92
|
-
exit('Try running: npm install arquebus --save')
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
class TableGuesser {
|
|
96
|
-
static CREATE_PATTERNS = [
|
|
97
|
-
/^create_(\w+)_table$/,
|
|
98
|
-
/^create_(\w+)$/
|
|
99
|
-
]
|
|
100
|
-
static CHANGE_PATTERNS = [
|
|
101
|
-
/.+_(to|from|in)_(\w+)_table$/,
|
|
102
|
-
/.+_(to|from|in)_(\w+)$/
|
|
103
|
-
]
|
|
104
|
-
static guess (migration) {
|
|
105
|
-
for (const pattern of TableGuesser.CREATE_PATTERNS) {
|
|
106
|
-
const matches = migration.match(pattern)
|
|
107
|
-
if (matches) {
|
|
108
|
-
return [matches[1], true]
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (const pattern of TableGuesser.CHANGE_PATTERNS) {
|
|
112
|
-
const matches = migration.match(pattern)
|
|
113
|
-
if (matches) {
|
|
114
|
-
return [matches[2], false]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return []
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { exit }
|
|
122
|
-
export { success }
|
|
123
|
-
export { twoColumnDetail }
|
|
124
|
-
export { findUpModulePath }
|
|
125
|
-
export { findModulePkg }
|
|
126
|
-
export { findUpConfig }
|
|
127
|
-
export { localModuleCheck }
|
|
128
|
-
export { getMigrationPaths }
|
|
129
|
-
export { TableGuesser }
|
|
130
|
-
|
|
131
|
-
export default {
|
|
132
|
-
exit,
|
|
133
|
-
success,
|
|
134
|
-
twoColumnDetail,
|
|
135
|
-
findUpModulePath,
|
|
136
|
-
findModulePkg,
|
|
137
|
-
findUpConfig,
|
|
138
|
-
localModuleCheck,
|
|
139
|
-
getMigrationPaths,
|
|
140
|
-
TableGuesser
|
|
141
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|