@lerna-dockerize/generate
Advanced tools
Comparing version 0.9.2 to 0.9.3-build.79ab6fc.0
@@ -31,3 +31,3 @@ "use strict"; | ||
const [_, fromStageName] = (_a = fromStage.match(/--from=(\S*)/)) !== null && _a !== void 0 ? _a : []; | ||
const isLocalStage = pkg.dockerFile.find(x => x.originalName === fromStageName); | ||
const isLocalStage = pkg.dockerFile.stages.find(x => x.originalName === fromStageName); | ||
if (isLocalStage) { | ||
@@ -34,0 +34,0 @@ return `COPY --from=${isLocalStage.name} ${chown || ''} ${filesList} ${destination}`; |
@@ -7,3 +7,3 @@ /// <reference types="lerna-package" /> | ||
import { Package } from './package'; | ||
import { DockerStage } from './read-dockerfile'; | ||
export declare function iterateDependencies(args: IGenerateArgs, lernaPackages: lernaPackage[], packageGraph: PackageGraph, concurrency: number, rejectCycles?: boolean, defaultDockerFile?: DockerStage[]): Promise<Package[]>; | ||
import { Dockerfile } from './read-dockerfile'; | ||
export declare function iterateDependencies(args: IGenerateArgs, lernaPackages: lernaPackage[], packageGraph: PackageGraph, concurrency: number, rejectCycles?: boolean, defaultDockerFile?: Dockerfile): Promise<Package[]>; |
@@ -30,6 +30,8 @@ "use strict"; | ||
} | ||
const baseStage = baseDockerFile[baseDockerFile.length - 1]; | ||
const baseStage = baseDockerFile.stages[baseDockerFile.stages.length - 1]; | ||
baseStage.name = 'base'; | ||
const result = []; | ||
for (let baseStage of baseDockerFile) { | ||
const result = [ | ||
...baseDockerFile.preStage, | ||
]; | ||
for (let baseStage of baseDockerFile.stages) { | ||
result.push(getDockerFileFromInstruction(baseStage.baseImage, baseStage.name, baseStage.platform)); | ||
@@ -80,3 +82,3 @@ result.push(...baseStage.stepsBeforeInstall); | ||
if (finalDockerfileName) { | ||
finalStages = await (0, read_dockerfile_1.readDockerfile)(finalDockerfileName); | ||
finalStages = (await (0, read_dockerfile_1.readDockerfile)(finalDockerfileName)).stages; | ||
} | ||
@@ -83,0 +85,0 @@ for (let finalStage of finalStages) { |
@@ -5,3 +5,3 @@ /// <reference types="lerna-package" /> | ||
import { Package as LernaPackage } from '@lerna/package'; | ||
import { DockerStage } from './read-dockerfile'; | ||
import { Dockerfile, DockerStage } from './read-dockerfile'; | ||
import { IGenerateArgs } from './args'; | ||
@@ -14,3 +14,3 @@ export declare type PackageMap = Map<string, Package>; | ||
private args; | ||
dockerFile?: DockerStage[]; | ||
dockerFile?: Dockerfile; | ||
constructor(name: string, lernaPackage: LernaPackage, lernaPackageGraphNode: PackageGraphNode, args: IGenerateArgs); | ||
@@ -20,3 +20,3 @@ get relativePath(): string; | ||
findDockerfile(): Promise<string | undefined>; | ||
loadDockerfile(defaultDockerFile?: DockerStage[]): Promise<DockerStage[]>; | ||
loadDockerfile(defaultDockerFile?: Dockerfile): Promise<Dockerfile>; | ||
getPackageStageNamePrefix(): string; | ||
@@ -23,0 +23,0 @@ getPrepareStageName(): string | undefined; |
@@ -51,3 +51,6 @@ "use strict"; | ||
} | ||
this.dockerFile = this.dockerFile.map((stage, i) => this.scopeDockerStage(stage, i)); | ||
this.dockerFile = { | ||
stages: this.dockerFile.stages.map((stage, i) => this.scopeDockerStage(stage, i)), | ||
preStage: this.dockerFile.preStage, | ||
}; | ||
return this.dockerFile; | ||
@@ -68,3 +71,3 @@ } | ||
} | ||
return this.dockerFile[this.dockerFile.length - 1].prepareStageName; | ||
return this.dockerFile.stages[this.dockerFile.stages.length - 1].prepareStageName; | ||
} | ||
@@ -79,3 +82,3 @@ getBuildStageName() { | ||
} | ||
return this.dockerFile[this.dockerFile.length - 1]; | ||
return this.dockerFile.stages[this.dockerFile.stages.length - 1]; | ||
} | ||
@@ -93,5 +96,5 @@ stageHasInstall(stage) { | ||
const result = []; | ||
for (let stage of this.dockerFile) { | ||
for (let stage of this.dockerFile.stages) { | ||
let baseImage = stage.baseImage; | ||
const baseImageIsLocalStage = this.dockerFile.find(x => x.originalName === baseImage); | ||
const baseImageIsLocalStage = this.dockerFile.stages.find(x => x.originalName === baseImage); | ||
if (baseImageIsLocalStage) { | ||
@@ -98,0 +101,0 @@ baseImage = baseImageIsLocalStage.name; |
@@ -16,8 +16,13 @@ interface IInstallOptions { | ||
} | ||
export declare function readDockerfile(path: string): Promise<DockerStage[]>; | ||
export interface Dockerfile { | ||
stages: DockerStage[]; | ||
preStage: string[]; | ||
} | ||
export declare function readDockerfile(path: string): Promise<Dockerfile>; | ||
export declare function readStage(steps: string[], startIndex: number): { | ||
stage: DockerStage; | ||
endIndex: number; | ||
preStage: string[]; | ||
} | undefined; | ||
export declare function splitInSteps(content: string): string[]; | ||
export {}; |
@@ -15,2 +15,3 @@ "use strict"; | ||
let currentStep = 0; | ||
let preStage = []; | ||
while (true) { | ||
@@ -23,2 +24,5 @@ const readStageResult = readStage(steps, currentStep); | ||
result.push(readStageResult.stage); | ||
if (preStage.length === 0 && readStageResult.preStage.length > 0) { | ||
preStage = readStageResult.preStage; | ||
} | ||
} | ||
@@ -28,3 +32,6 @@ if (result.length === 0) { | ||
} | ||
return result; | ||
return { | ||
preStage: preStage, | ||
stages: result, | ||
}; | ||
} | ||
@@ -37,3 +44,4 @@ exports.readDockerfile = readDockerfile; | ||
let platform; | ||
const isStageFromClause = /(FROM|from)(\s--platform=(\S+))? ([a-zA-Z0-9:_\-@.\/]*)( as ([a-zA-Z0-9:_-]*))?/; | ||
const preStage = []; | ||
const isStageFromClause = /(FROM|from)(\s--platform=(\S+))? ([a-zA-Z0-9:_\-@.\/${}]*)( as ([a-zA-Z0-9:_-]*))?/; | ||
for (;; i++) { | ||
@@ -51,2 +59,3 @@ if (i >= steps.length) { | ||
} | ||
preStage.push(steps[i]); | ||
} | ||
@@ -88,2 +97,3 @@ const stepsBeforeInstall = []; | ||
}, | ||
preStage, | ||
}; | ||
@@ -90,0 +100,0 @@ } |
{ | ||
"name": "@lerna-dockerize/generate", | ||
"version": "0.9.2", | ||
"version": "0.9.3-build.79ab6fc.0", | ||
"description": "A dockerfile generator for lerna projects", | ||
@@ -29,4 +29,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@lerna-dockerize/cli": "0.9.2", | ||
"@lerna-dockerize/logger": "0.9.2", | ||
"@lerna-dockerize/cli": "0.9.3-build.79ab6fc.0", | ||
"@lerna-dockerize/logger": "0.9.3-build.79ab6fc.0", | ||
"@lerna/command": "^4.0.0", | ||
@@ -33,0 +33,0 @@ "@lerna/filter-options": "^4.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68518
779
+ Added@lerna-dockerize/cli@0.9.3-build.79ab6fc.0(transitive)
+ Added@lerna-dockerize/logger@0.9.3-build.79ab6fc.0(transitive)
- Removed@lerna-dockerize/cli@0.9.2(transitive)
- Removed@lerna-dockerize/logger@0.9.2(transitive)