Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
23051355
Commit
23051355
authored
6 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
fix: properly migrate pathRules
parent
72742f99
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/config/migration.js
+26
-21
26 additions, 21 deletions
lib/config/migration.js
test/config/__snapshots__/migration.spec.js.snap
+29
-13
29 additions, 13 deletions
test/config/__snapshots__/migration.spec.js.snap
test/config/migration.spec.js
+4
-4
4 additions, 4 deletions
test/config/migration.spec.js
with
59 additions
and
38 deletions
lib/config/migration.js
+
26
−
21
View file @
23051355
...
...
@@ -20,7 +20,6 @@ const removedOptions = [
'
groupCommitMessage
'
,
'
groupPrTitle
'
,
'
groupPrBody
'
,
'
pathRules
'
,
];
// Returns a migrated config
...
...
@@ -34,19 +33,22 @@ function migrateConfig(config) {
}
let
isMigrated
=
false
;
const
migratedConfig
=
deepcopy
(
config
);
if
(
Array
.
isArray
(
migratedConfig
.
pathRules
)
&&
migratedConfig
.
pathRules
.
length
)
{
isMigrated
=
true
;
migratedConfig
.
packageRules
=
migratedConfig
.
pathRules
.
concat
(
migratedConfig
.
packageRules
||
[]
);
}
for
(
const
[
key
,
val
]
of
Object
.
entries
(
config
))
{
if
(
removedOptions
.
includes
(
key
))
{
isMigrated
=
true
;
delete
migratedConfig
[
key
];
}
else
if
(
key
===
'
pathRules
'
)
{
isMigrated
=
true
;
if
(
Array
.
isArray
(
val
))
{
migratedConfig
.
packageRules
=
migratedConfig
.
packageRules
||
[];
const
migratedPathRules
=
migratedConfig
.
pathRules
.
map
(
p
=>
migrateConfig
(
p
).
migratedConfig
);
migratedConfig
.
packageRules
=
migratedPathRules
.
concat
(
migratedConfig
.
packageRules
);
}
delete
migratedConfig
.
pathRules
;
}
else
if
(
key
===
'
semanticPrefix
'
)
{
isMigrated
=
true
;
delete
migratedConfig
.
semanticPrefix
;
...
...
@@ -113,8 +115,9 @@ function migrateConfig(config) {
}
}
else
if
(
key
===
'
packages
'
)
{
isMigrated
=
true
;
migratedConfig
.
packageRules
=
migratedConfig
.
packages
.
map
(
p
=>
migrateConfig
(
p
).
migratedConfig
migratedConfig
.
packageRules
=
migratedConfig
.
packageRules
||
[];
migratedConfig
.
packageRules
=
migratedConfig
.
packageRules
.
concat
(
migratedConfig
.
packages
.
map
(
p
=>
migrateConfig
(
p
).
migratedConfig
)
);
delete
migratedConfig
.
packages
;
}
else
if
(
key
===
'
excludedPackageNames
'
)
{
...
...
@@ -227,10 +230,11 @@ function migrateConfig(config) {
if
(
isObject
(
depType
))
{
const
depTypeName
=
depType
.
depType
;
if
(
depTypeName
)
{
migratedConfig
[
depTypeName
]
=
migrateConfig
(
depType
).
migratedConfig
;
delete
migratedConfig
[
depTypeName
].
depType
;
migratedConfig
.
packageRules
=
migratedConfig
.
packageRules
||
[];
const
newPackageRule
=
migrateConfig
(
depType
).
migratedConfig
;
delete
newPackageRule
.
depType
;
newPackageRule
.
depTypeList
=
[
depTypeName
];
migratedConfig
.
packageRules
.
push
(
newPackageRule
);
}
}
});
...
...
@@ -263,24 +267,25 @@ function migrateConfig(config) {
migratedConfig
.
node
=
subMigrate
.
migratedConfig
;
}
}
else
if
(
isObject
(
val
))
{
const
subMigrate
=
migrateConfig
(
val
);
const
subMigrate
=
migrateConfig
(
migratedConfig
[
key
]
);
if
(
subMigrate
.
isMigrated
)
{
isMigrated
=
true
;
migratedConfig
[
key
]
=
subMigrate
.
migratedConfig
;
}
}
else
if
(
Array
.
isArray
(
val
))
{
migratedConfig
[
key
]
=
[];
for
(
const
item
of
val
)
{
const
newArray
=
[];
for
(
const
item
of
migratedConfig
[
key
]
)
{
if
(
isObject
(
item
))
{
const
arrMigrate
=
migrateConfig
(
item
);
migratedConfig
[
key
]
.
push
(
arrMigrate
.
migratedConfig
);
newArray
.
push
(
arrMigrate
.
migratedConfig
);
if
(
arrMigrate
.
isMigrated
)
{
isMigrated
=
true
;
}
}
else
{
migratedConfig
[
key
]
.
push
(
item
);
newArray
.
push
(
item
);
}
}
migratedConfig
[
key
]
=
newArray
;
}
}
return
{
isMigrated
,
migratedConfig
};
...
...
This diff is collapsed.
Click to expand it.
test/config/__snapshots__/migration.spec.js.snap
+
29
−
13
View file @
23051355
...
...
@@ -57,17 +57,15 @@ Object {
],
},
"onboarding": false,
"optionalDependencies": Object {
"major": Object {
"automerge": false,
},
"minor": Object {
"automerge": true,
},
"respectLatest": false,
"schedule": "before 5am on Monday",
},
"packageRules": Array [
Object {
"extends": Array [
"foo",
],
"paths": Array [
"examples/**",
],
},
Object {
"excludePackageNames": "foo",
"groupName": "angular packages",
...
...
@@ -88,6 +86,19 @@ Object {
"ang",
],
},
Object {
"depTypeList": Array [
"optionalDependencies",
],
"major": Object {
"automerge": false,
},
"minor": Object {
"automerge": true,
},
"respectLatest": false,
"schedule": "before 5am on Monday",
},
],
"patch": Object {
"automerge": true,
...
...
@@ -130,9 +141,14 @@ Object {
exports[`config/migration migrateConfig(config, parentConfig) it migrates subconfig 1`] = `
Object {
"lockFileMaintenance": Object {
"optionalDependencies": Object {
"respectLatest": false,
},
"packageRules": Array [
Object {
"depTypeList": Array [
"optionalDependencies",
],
"respectLatest": false,
},
],
},
}
`;
...
...
This diff is collapsed.
Click to expand it.
test/config/migration.spec.js
+
4
−
4
View file @
23051355
...
...
@@ -77,11 +77,11 @@ describe('config/migration', () => {
config
,
parentConfig
);
expect
(
migratedConfig
).
toMatchSnapshot
();
expect
(
isMigrated
).
toBe
(
true
);
expect
(
migratedConfig
.
depTypes
).
not
.
toBeDefined
();
expect
(
migratedConfig
.
optionalDependencies
.
respectLatest
).
toBe
(
false
);
expect
(
migratedConfig
.
automerge
).
toEqual
(
false
);
expect
(
migratedConfig
).
toMatchSnapshot
(
);
expect
(
migratedConfig
.
packageRules
).
toHaveLength
(
5
);
});
it
(
'
migrates before and after schedules
'
,
()
=>
{
const
config
=
{
...
...
@@ -238,9 +238,9 @@ describe('config/migration', () => {
);
expect
(
isMigrated
).
toBe
(
true
);
expect
(
migratedConfig
).
toMatchSnapshot
();
expect
(
migratedConfig
.
lockFileMaintenance
.
depTypes
).
not
.
toBeDefined
(
);
expect
(
migratedConfig
.
lockFileMaintenance
.
packageRules
).
toHaveLength
(
1
);
expect
(
migratedConfig
.
lockFileMaintenance
.
optionalDependencies
.
respectLatest
migratedConfig
.
lockFileMaintenance
.
packageRules
[
0
]
.
respectLatest
).
toBe
(
false
);
});
it
(
'
it migrates node to travis
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment