Skip to content

Commit

Permalink
refactor(project-info.js): drop support for legacy configuation file
Browse files Browse the repository at this point in the history
Earlier versions of the cli used to keep the image name in a separate file in the manifest
directory. This was removed in favor of the new json file but the cli continued to migrate from this
old file. Migration code path is now being removed. To properly cleanup your project, make sure you
run the previous major version of the tool at least once, or manually remove the `docker-image` file
from `.libdragon` folder.

BREAKING CHANGE: The cli will no longer migrate the `.libdragon/docker-image` Either make sure you
run the 10.x version once for your project or remove the file manually.
  • Loading branch information
anacierdem committed Nov 11, 2023
1 parent 8c768fd commit 880f38d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
2 changes: 0 additions & 2 deletions modules/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ module.exports = /** @type {const} */ ({
STATUS_ERROR: 1,
STATUS_BAD_PARAM: 2,
STATUS_VALIDATION_ERROR: 4,

IMAGE_FILE: 'docker-image', // deprecated
});
27 changes: 2 additions & 25 deletions modules/project-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const {
CONFIG_FILE,
DOCKER_HUB_IMAGE,
DEFAULT_STRATEGY,
IMAGE_FILE,
LIBDRAGON_SUBMODULE,
CACHED_CONTAINER_FILE,
CONTAINER_TARGET_PATH,
Expand Down Expand Up @@ -159,15 +158,7 @@ const readProjectInfo = async function (optionInfo) {
return /** @type {NoProjectInfo} */ (optionInfo);
}

const migratedRoot = await findLibdragonRoot();

// Look for old one for backwards compatibility
const projectRoot =
migratedRoot ??
(await findLibdragonRoot(
'.',
path.join(LIBDRAGON_PROJECT_MANIFEST, IMAGE_FILE)
));
const projectRoot = await findLibdragonRoot();

if (
!projectRoot &&
Expand Down Expand Up @@ -204,7 +195,7 @@ const readProjectInfo = async function (optionInfo) {

log(`Project root: ${info.root}`, true);

if (migratedRoot) {
if (projectRoot) {
info = {
...info,
...JSON.parse(
Expand All @@ -214,20 +205,6 @@ const readProjectInfo = async function (optionInfo) {
)
),
};
} else {
// Cleanup old files and migrate to the new config file
const imageFile = path.join(
info.root,
LIBDRAGON_PROJECT_MANIFEST,
IMAGE_FILE
);
if (await fileExists(imageFile)) {
info.imageName = (
await fs.readFile(imageFile, { encoding: 'utf8' })
).trim();
// Immediately update the config as this is the first migration
await Promise.all([writeProjectInfo(info), fs.rm(imageFile)]);
}
}

if (!process.env.DOCKER_CONTAINER) {
Expand Down

0 comments on commit 880f38d

Please sign in to comment.