Skip to content

Commit

Permalink
fix(wb): package name detection
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Nov 6, 2023
1 parent 06d5dc6 commit 53b62d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions packages/wb/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ export class Project {

@memoizeOne
get name(): string {
return this.rootPackageJson.name || 'unknown';
return this.packageJson.name || 'unknown';
}

@memoizeOne
get nameWithoutNamespace(): string {
const name = this.rootPackageJson.name || 'unknown';
const index = name.lastIndexOf('/');
return index === -1 ? name : name.slice(index + 1);
get dockerImageName(): string {
const name = this.packageJson.name || 'unknown';
return name.replaceAll('@', '').replaceAll('/', '-');
}

@memoizeOne
Expand Down
6 changes: 3 additions & 3 deletions packages/wb/src/scripts/dockerScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DockerScripts {
: '';
return `cd ${path.dirname(project.findFile('Dockerfile'))}
&& ${prefix}YARN wb optimizeForDockerBuild --outside
&& YARN wb retry -- docker build -t ${project.nameWithoutNamespace}
&& YARN wb retry -- docker build -t ${project.dockerImageName}
--build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)
--build-arg WB_ENV=${project.env.WB_ENV}
--build-arg WB_VERSION=dev .`;
Expand All @@ -29,11 +29,11 @@ class DockerScripts {
}
start(project: Project, additionalOptions = '', additionalArgs = ''): string {
spawnSyncOnExit(this.stop(project), project);
return `docker run --rm -it -p 8080:8080 --name ${project.nameWithoutNamespace} ${additionalOptions} ${project.nameWithoutNamespace} ${additionalArgs}`;
return `docker run --rm -it -p 8080:8080 --name ${project.dockerImageName} ${additionalOptions} ${project.dockerImageName} ${additionalArgs}`;
}

stop(project: Project): string {
return `true $(docker rm -f $(docker container ls -q -f name=${project.nameWithoutNamespace}) 2> /dev/null)`;
return `true $(docker rm -f $(docker container ls -q -f name=${project.dockerImageName}) 2> /dev/null)`;
}

stopAll(): string {
Expand Down

0 comments on commit 53b62d3

Please sign in to comment.