fix(core): update
This commit is contained in:
parent
7eeca992b0
commit
dc809a6023
2
test/assets/Dockerfile_hello_##version##
Normal file
2
test/assets/Dockerfile_hello_##version##
Normal file
@ -0,0 +1,2 @@
|
||||
FROM mygroup/myrepo:sometag2
|
||||
RUN apt-get update
|
20
test/test.ts
20
test/test.ts
@ -19,26 +19,20 @@ process.cwd = () => {
|
||||
return path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), 'assets/');
|
||||
};
|
||||
|
||||
let npmci: typeof import('../ts/index.js');
|
||||
|
||||
type TNpmciTypes = typeof import('../ts/index.js');
|
||||
|
||||
tap.preTask('should import npmci', async () => {
|
||||
npmci = await import('../ts/index.js');
|
||||
});
|
||||
import type * as npmciTypes from '../ts/index.js';
|
||||
const npmci = await import('../ts/index.js');
|
||||
|
||||
// ======
|
||||
// Docker
|
||||
// ======
|
||||
|
||||
let dockerfile1: npmci.Dockerfile;
|
||||
let dockerfile2: npmci.Dockerfile;
|
||||
let sortableArray: npmci.Dockerfile[];
|
||||
let dockerfile1: npmciTypes.Dockerfile;
|
||||
let dockerfile2: npmciTypes.Dockerfile;
|
||||
let sortableArray: npmciTypes.Dockerfile[];
|
||||
|
||||
tap.test('should return valid Dockerfiles', async () => {
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
await npmciInstance.start();
|
||||
await npmciInstance.start();
|
||||
dockerfile1 = new npmci.Dockerfile(npmciInstance.dockerManager, {
|
||||
filePath: './Dockerfile',
|
||||
read: true,
|
||||
@ -55,7 +49,7 @@ tap.test('should read a directory of Dockerfiles', async () => {
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
await npmciInstance.start();
|
||||
return npmci.Dockerfile.readDockerfiles(npmciInstance.dockerManager).then(
|
||||
async (readDockerfilesArrayArg: npmci.Dockerfile[]) => {
|
||||
async (readDockerfilesArrayArg: npmciTypes.Dockerfile[]) => {
|
||||
sortableArray = readDockerfilesArrayArg;
|
||||
return expect(readDockerfilesArrayArg[1].version).toEqual('sometag1');
|
||||
}
|
||||
@ -64,7 +58,7 @@ tap.test('should read a directory of Dockerfiles', async () => {
|
||||
|
||||
tap.test('should sort an array of Dockerfiles', async () => {
|
||||
return npmci.Dockerfile.sortDockerfiles(sortableArray).then(
|
||||
async (sortedArrayArg: npmci.Dockerfile[]) => {
|
||||
async (sortedArrayArg: npmciTypes.Dockerfile[]) => {
|
||||
console.log(sortedArrayArg);
|
||||
}
|
||||
);
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@ship.zone/npmci',
|
||||
version: '4.1.28',
|
||||
version: '4.1.29',
|
||||
description: 'node and docker in gitlab ci on steroids'
|
||||
}
|
||||
|
@ -117,24 +117,24 @@ export class Dockerfile {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a version for a docker file
|
||||
* @execution SYNC
|
||||
*/
|
||||
public static dockerFileVersion(dockerfileInstanceArg: Dockerfile, dockerfileNameArg: string): string {
|
||||
let versionString: string;
|
||||
const versionRegex = /Dockerfile_([^:_]*)$/;
|
||||
const regexResultArray = versionRegex.exec(dockerfileNameArg);
|
||||
if (regexResultArray && regexResultArray.length === 2) {
|
||||
versionString = regexResultArray[1];
|
||||
} else {
|
||||
versionString = 'latest';
|
||||
}
|
||||
versionString = versionString.replace(
|
||||
'##version##',
|
||||
dockerfileInstanceArg.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version
|
||||
);
|
||||
return versionString;
|
||||
* returns a version for a docker file
|
||||
* @execution SYNC
|
||||
*/
|
||||
public static dockerFileVersion(dockerfileInstanceArg: Dockerfile, dockerfileNameArg: string): string {
|
||||
let versionString: string;
|
||||
const versionRegex = /Dockerfile_(.+)$/;
|
||||
const regexResultArray = versionRegex.exec(dockerfileNameArg);
|
||||
if (regexResultArray && regexResultArray.length === 2) {
|
||||
versionString = regexResultArray[1];
|
||||
} else {
|
||||
versionString = 'latest';
|
||||
}
|
||||
versionString = versionString.replace(
|
||||
'##version##',
|
||||
dockerfileInstanceArg.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version
|
||||
);
|
||||
return versionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the docker base image for a Dockerfile
|
||||
|
Loading…
Reference in New Issue
Block a user