diff --git a/lib/build/builder.ts b/lib/build/builder.ts index e4c099e..aeae2b1 100644 --- a/lib/build/builder.ts +++ b/lib/build/builder.ts @@ -26,7 +26,7 @@ import * as stream from 'node:stream'; import * as tar from 'tar-stream'; // Import hook definitions -import * as Plugin from './plugin'; +import type * as Plugin from './plugin'; import * as Utils from './utils'; export type ErrorHandler = (error: Error) => void; diff --git a/lib/build/utils.ts b/lib/build/utils.ts index 08dde7f..a9a59a8 100644 --- a/lib/build/utils.ts +++ b/lib/build/utils.ts @@ -16,7 +16,7 @@ */ import * as klaw from 'klaw'; -import * as Plugin from './plugin'; +import type * as Plugin from './plugin'; /** * Given a docker 'arrow message' containing a sha representing diff --git a/lib/dockerfile/index.ts b/lib/dockerfile/index.ts index 7063c1a..db48000 100644 --- a/lib/dockerfile/index.ts +++ b/lib/dockerfile/index.ts @@ -33,7 +33,7 @@ export function process( return line[0] !== '#' ? lodash.template(line, { interpolate: /%%([A-Z][A-Z_]+)%%/ })( variables, - ) + ) : line; }) .join('\n'); diff --git a/lib/multibuild/build-metadata.ts b/lib/multibuild/build-metadata.ts index cc6617c..9ab12cb 100644 --- a/lib/multibuild/build-metadata.ts +++ b/lib/multibuild/build-metadata.ts @@ -15,17 +15,19 @@ * limitations under the License. */ -import { Either, isLeft } from 'fp-ts/lib/Either'; -import * as t from 'io-ts'; +import type { Either } from 'fp-ts/lib/Either'; +import { isLeft } from 'fp-ts/lib/Either'; +import type * as t from 'io-ts'; import { reporter } from 'io-ts-reporters'; import * as jsYaml from 'js-yaml'; import * as _ from 'lodash'; import * as Path from 'path'; import type * as Stream from 'stream'; -import * as tar from 'tar-stream'; +import type * as tar from 'tar-stream'; import * as TarUtils from 'tar-utils'; -import { BalenaYml, parsedBalenaYml, ParsedBalenaYml } from './build-secrets'; +import type { BalenaYml, ParsedBalenaYml } from './build-secrets'; +import { parsedBalenaYml } from './build-secrets'; import { BalenaYMLValidationError, MultipleBalenaConfigFilesError, @@ -33,9 +35,9 @@ import { RegistrySecretValidationError, } from './errors'; import * as PathUtils from './path-utils'; +import type { RegistrySecrets } from './registry-secrets'; import { addCanonicalDockerHubEntry, - RegistrySecrets, RegistrySecretValidator, } from './registry-secrets'; diff --git a/lib/multibuild/build-secrets/index.ts b/lib/multibuild/build-secrets/index.ts index 123908e..183ee2e 100644 --- a/lib/multibuild/build-secrets/index.ts +++ b/lib/multibuild/build-secrets/index.ts @@ -27,7 +27,8 @@ import * as dockerfileTemplate from '../../dockerfile'; import type BuildMetadata from '../build-metadata'; import { BuildSecretMissingError, SecretPopulationError } from '../errors'; -import { PermissiveVarList, VarList } from '../validation-types/varlist'; +import type { VarList } from '../validation-types/varlist'; +import { PermissiveVarList } from '../validation-types/varlist'; import { pipeline } from 'stream'; export const secretType = t.interface({ diff --git a/lib/multibuild/build.ts b/lib/multibuild/build.ts index 7ba1b0a..78ee747 100644 --- a/lib/multibuild/build.ts +++ b/lib/multibuild/build.ts @@ -20,7 +20,8 @@ import * as _ from 'lodash'; import * as semver from 'semver'; import * as stream from 'stream'; -import { Builder, BuildHooks, FromTagInfo } from '../build'; +import type { BuildHooks, FromTagInfo } from '../build'; +import { Builder } from '../build'; import type { SecretsPopulationMap } from './build-secrets'; import type { BuildTask } from './build-task'; diff --git a/lib/multibuild/index.ts b/lib/multibuild/index.ts index df16270..064fcb5 100644 --- a/lib/multibuild/index.ts +++ b/lib/multibuild/index.ts @@ -26,13 +26,13 @@ import * as Compose from '../parse'; import { runBuildTask } from './build'; import BuildMetadata from './build-metadata'; +import type { SecretsPopulationMap } from './build-secrets'; import { BalenaYml, generateSecretPopulationMap, ParsedBalenaYml, populateSecrets, removeSecrets, - SecretsPopulationMap, } from './build-secrets'; import type { BuildTask } from './build-task'; import * as contracts from './contracts'; diff --git a/lib/parse/compose.ts b/lib/parse/compose.ts index 74e8ec6..7b639c7 100644 --- a/lib/parse/compose.ts +++ b/lib/parse/compose.ts @@ -1,4 +1,4 @@ -import { Readable } from 'stream'; +import type { Readable } from 'stream'; import * as _ from 'lodash'; import * as path from 'path'; @@ -13,7 +13,7 @@ import { SchemaVersion, validate, } from './schemas'; -import { +import type { BuildConfig, Composition, Dict, diff --git a/lib/release/api.ts b/lib/release/api.ts index 4630181..381cf30 100644 --- a/lib/release/api.ts +++ b/lib/release/api.ts @@ -2,9 +2,9 @@ import pMap = require('p-map'); import type { PinejsClientCore, RetryParameters } from 'pinejs-client-core'; import { PinejsClientRequest } from 'pinejs-client-request'; import * as models from './models'; -import { Dict } from './types'; +import type { Dict } from './types'; -import { Composition } from '../../lib/parse'; +import type { Composition } from '../../lib/parse'; const MAX_CONCURRENT_REQUESTS = 5; diff --git a/lib/resolve/index.ts b/lib/resolve/index.ts index e004cb8..572ec77 100644 --- a/lib/resolve/index.ts +++ b/lib/resolve/index.ts @@ -15,7 +15,8 @@ * limitations under the License. */ import * as _ from 'lodash'; -import { Readable, pipeline } from 'stream'; +import type { Readable } from 'stream'; +import { pipeline } from 'stream'; import * as tar from 'tar-stream'; import * as TarUtils from 'tar-utils'; diff --git a/lib/resolve/resolver.ts b/lib/resolve/resolver.ts index 4dcadf3..008e52e 100644 --- a/lib/resolve/resolver.ts +++ b/lib/resolve/resolver.ts @@ -1,6 +1,6 @@ import Bundle from './bundle'; import { FileInfo } from './fileInfo'; -import { ParsedPathPlus } from './utils'; +import type { ParsedPathPlus } from './utils'; // Make the external types available to implementers export { Bundle, FileInfo }; diff --git a/lib/resolve/resolvers/archDockerfile.ts b/lib/resolve/resolvers/archDockerfile.ts index b33e9cc..2a84521 100644 --- a/lib/resolve/resolvers/archDockerfile.ts +++ b/lib/resolve/resolvers/archDockerfile.ts @@ -18,8 +18,9 @@ import { posix } from 'path'; import * as DockerfileTemplate from '../../dockerfile'; -import { Bundle, FileInfo, Resolver } from '../resolver'; -import { ParsedPathPlus, removeExtension } from '../utils'; +import type { Bundle, FileInfo, Resolver } from '../resolver'; +import type { ParsedPathPlus } from '../utils'; +import { removeExtension } from '../utils'; import { DockerfileTemplateVariableError } from './dockerfileTemplate'; // Internal tuple to pass files and their extensions around diff --git a/lib/resolve/resolvers/dockerfile.ts b/lib/resolve/resolvers/dockerfile.ts index 75c28de..324c8df 100644 --- a/lib/resolve/resolvers/dockerfile.ts +++ b/lib/resolve/resolvers/dockerfile.ts @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Bundle } from '../resolver'; +import type { Bundle } from '../resolver'; -import { FileInfo, Resolver } from '../resolver'; -import { ParsedPathPlus } from '../utils'; +import type { FileInfo, Resolver } from '../resolver'; +import type { ParsedPathPlus } from '../utils'; export class DockerfileResolver implements Resolver { public priority = 0; diff --git a/lib/resolve/resolvers/dockerfileTemplate.ts b/lib/resolve/resolvers/dockerfileTemplate.ts index 4024ecb..99fb5a4 100644 --- a/lib/resolve/resolvers/dockerfileTemplate.ts +++ b/lib/resolve/resolvers/dockerfileTemplate.ts @@ -17,8 +17,9 @@ import { TypedError } from 'typed-error'; import * as DockerfileTemplate from '../../dockerfile'; -import { Bundle, FileInfo, Resolver } from '../resolver'; -import { ParsedPathPlus, removeExtension } from '../utils'; +import type { Bundle, FileInfo, Resolver } from '../resolver'; +import type { ParsedPathPlus } from '../utils'; +import { removeExtension } from '../utils'; export class DockerfileTemplateVariableError extends TypedError {} diff --git a/lib/resolve/resolvers/nodeResolver.ts b/lib/resolve/resolvers/nodeResolver.ts index c2d76d6..85d56ab 100644 --- a/lib/resolve/resolvers/nodeResolver.ts +++ b/lib/resolve/resolvers/nodeResolver.ts @@ -23,8 +23,8 @@ import { promisify } from 'util'; const getAsync = promisify(request.get); -import { Bundle, FileInfo, Resolver } from '../resolver'; -import { ParsedPathPlus } from '../utils'; +import type { Bundle, FileInfo, Resolver } from '../resolver'; +import type { ParsedPathPlus } from '../utils'; const versionTest = RegExp.prototype.test.bind(/^[0-9]+\.[0-9]+\.[0-9]+$/); const getDeviceTypeVersions = memoize( @@ -32,7 +32,7 @@ const getDeviceTypeVersions = memoize( const tags: string[] = []; // 100 is the max page size let nextUrl: string | undefined = - `https://hub.docker.com/v2/repositories/resin/${deviceType}-node/tags/?page_size=100`; + `https://hub.docker.com/v2/repositories/balenalib/${deviceType}-node/tags/?page_size=100`; while (nextUrl != null) { const res = ( await getAsync({ @@ -41,11 +41,14 @@ const getDeviceTypeVersions = memoize( }) ).body as { results: Array<{ name: string }>; next?: string }; - const curr: string[] = res.results - .map(({ name }) => name) - .filter(versionTest); + // sometimes the last result is undefined + if (res.results !== undefined) { + const curr: string[] = res.results + .map(({ name }) => name) + .filter(versionTest); + tags.push(...curr); + } - tags.push(...curr); nextUrl = res.next; } diff --git a/lib/resolve/utils.ts b/lib/resolve/utils.ts index f707872..9def89a 100644 --- a/lib/resolve/utils.ts +++ b/lib/resolve/utils.ts @@ -15,7 +15,8 @@ * limitations under the License. */ -import { ParsedPath, posix } from 'path'; +import type { ParsedPath } from 'path'; +import { posix } from 'path'; export interface ParsedPathPlus extends ParsedPath { minusExt: string; diff --git a/test/build/all.spec.ts b/test/build/all.spec.ts index 70fe0e5..874d104 100644 --- a/test/build/all.spec.ts +++ b/test/build/all.spec.ts @@ -23,7 +23,8 @@ import * as url from 'url'; import * as proxyquire from 'proxyquire'; -import { Builder, BuildHooks } from '../../lib/build'; +import type { BuildHooks } from '../../lib/build'; +import { Builder } from '../../lib/build'; import * as Utils from '../../lib/build/utils'; const TEST_FILE_PATH = 'test/build/test-files'; diff --git a/test/build/build_stream.spec.ts b/test/build/build_stream.spec.ts index 2c69ba9..e0e26e2 100644 --- a/test/build/build_stream.spec.ts +++ b/test/build/build_stream.spec.ts @@ -15,7 +15,8 @@ * limitations under the License. */ import { assert } from 'chai'; -import { Readable, Stream, Writable } from 'stream'; +import type { Readable, Writable } from 'stream'; +import { Stream } from 'stream'; import * as proxyquire from 'proxyquire'; diff --git a/test/multibuild/build-utils.ts b/test/multibuild/build-utils.ts index acffb1f..0a0bc8a 100644 --- a/test/multibuild/build-utils.ts +++ b/test/multibuild/build-utils.ts @@ -18,12 +18,12 @@ import * as Dockerode from 'dockerode'; import * as fs from 'fs'; import * as Path from 'path'; -import * as Stream from 'stream'; -import * as tar from 'tar-stream'; +import type * as Stream from 'stream'; +import type * as tar from 'tar-stream'; import * as Url from 'url'; import BuildMetadata from '../../lib/multibuild/build-metadata'; -import { BalenaYml } from '../../lib/multibuild/build-secrets'; +import type { BalenaYml } from '../../lib/multibuild/build-secrets'; export const TEST_FILES_PATH = 'test/multibuild/test-files'; diff --git a/test/multibuild/build.spec.ts b/test/multibuild/build.spec.ts index 1b11ba7..5db24b5 100644 --- a/test/multibuild/build.spec.ts +++ b/test/multibuild/build.spec.ts @@ -30,12 +30,8 @@ import { import * as Compose from '../../lib/parse'; -import { - splitBuildStream, - BuildTask, - BuildProcessError, - LocalImage, -} from '../../lib/multibuild'; +import type { BuildTask, LocalImage } from '../../lib/multibuild'; +import { splitBuildStream, BuildProcessError } from '../../lib/multibuild'; import { runBuildTask } from '../../lib/multibuild/build'; import { resolveTask } from '../../lib/multibuild/resolve'; diff --git a/test/multibuild/manifests.spec.ts b/test/multibuild/manifests.spec.ts index b974119..58d208e 100644 --- a/test/multibuild/manifests.spec.ts +++ b/test/multibuild/manifests.spec.ts @@ -15,14 +15,16 @@ * limitations under the License. */ +import type { + DockerImageManifest, + DockerImageManifestPlatform, +} from '../../lib/multibuild/manifests'; import { MEDIATYPE_MANIFEST_V1, MEDIATYPE_MANIFEST_LIST_V2, MEDIATYPE_MANIFEST_V2, MEDIATYPE_OCI_IMAGE_INDEX_V1, getManifest, - DockerImageManifest, - DockerImageManifestPlatform, } from '../../lib/multibuild/manifests'; import { expect } from 'chai'; import * as Dockermodem from 'docker-modem'; diff --git a/test/multibuild/multibuild.spec.ts b/test/multibuild/multibuild.spec.ts index c94bd0d..4b6b442 100644 --- a/test/multibuild/multibuild.spec.ts +++ b/test/multibuild/multibuild.spec.ts @@ -18,7 +18,7 @@ import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as fs from 'fs'; -import * as Stream from 'stream'; +import type * as Stream from 'stream'; import { checkExists, @@ -27,7 +27,8 @@ import { TEST_FILES_PATH, } from './build-utils'; -import { performBuilds, BuildTask, LocalImage } from '../../lib/multibuild'; +import type { BuildTask, LocalImage } from '../../lib/multibuild'; +import { performBuilds } from '../../lib/multibuild'; import BuildMetadata from '../../lib/multibuild/build-metadata'; chai.use(chaiAsPromised); diff --git a/test/multibuild/registry-secrets.spec.ts b/test/multibuild/registry-secrets.spec.ts index 9f4d478..e076d07 100644 --- a/test/multibuild/registry-secrets.spec.ts +++ b/test/multibuild/registry-secrets.spec.ts @@ -23,9 +23,9 @@ import * as fs from 'fs'; import { normalize } from '../../lib/parse'; +import type { RegistrySecrets } from '../../lib/multibuild'; import { addCanonicalDockerHubEntry, - RegistrySecrets, RegistrySecretValidator, RegistrySecretValidationError, splitBuildStream, diff --git a/test/multibuild/resolve.spec.ts b/test/multibuild/resolve.spec.ts index d644614..2774749 100644 --- a/test/multibuild/resolve.spec.ts +++ b/test/multibuild/resolve.spec.ts @@ -1,10 +1,10 @@ import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as fs from 'fs'; -import { Pack } from 'tar-stream'; +import type { Pack } from 'tar-stream'; import BuildMetadata from '../../lib/multibuild/build-metadata'; -import { BuildTask } from '../../lib/multibuild'; +import type { BuildTask } from '../../lib/multibuild'; import { resolveTask } from '../../lib/multibuild/resolve'; import { TEST_FILES_PATH } from './build-utils'; diff --git a/test/multibuild/stream.spec.ts b/test/multibuild/stream.spec.ts index d9e1b66..25d8465 100644 --- a/test/multibuild/stream.spec.ts +++ b/test/multibuild/stream.spec.ts @@ -18,7 +18,7 @@ import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as fs from 'fs'; import * as _ from 'lodash'; -import * as Stream from 'stream'; +import type * as Stream from 'stream'; import * as tar from 'tar-stream'; import * as Compose from '../../lib/parse'; diff --git a/test/resolve/all.spec.ts b/test/resolve/all.spec.ts index eff512e..6f593db 100644 --- a/test/resolve/all.spec.ts +++ b/test/resolve/all.spec.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as fs from 'fs'; -import { Readable } from 'stream'; +import type { Readable } from 'stream'; import * as tar from 'tar-stream'; import * as TarUtils from 'tar-utils'; @@ -309,13 +309,14 @@ describe('Resolvers', () => { ); }); - it.skip('should resolve a nodeJS project', function () { - this.timeout(3600000); + it('should resolve a nodeJS project', function () { + // test often takes around 40 sec to complete + this.timeout(180000); const deviceType = 'raspberrypi3'; return testResolveInput({ deviceType, dockerfileContentMatcher: (contents) => - contents.startsWith(`FROM resin/${deviceType}-node:10.0.0-onbuild`), + contents.startsWith(`FROM resin/${deviceType}-node:18.0.0-onbuild`), expectedResolvedDockerfilePath: undefined, expectedResolverName: 'NodeJS', specifiedDockerfilePath: undefined, diff --git a/test/resolve/test-files/NodeProject/archive.tar b/test/resolve/test-files/NodeProject/archive.tar index d9078c2..9be6cb2 100644 Binary files a/test/resolve/test-files/NodeProject/archive.tar and b/test/resolve/test-files/NodeProject/archive.tar differ diff --git a/test/resolve/test-files/NodeProject/archive/package.json b/test/resolve/test-files/NodeProject/archive/package.json index 7837743..e181dbf 100644 --- a/test/resolve/test-files/NodeProject/archive/package.json +++ b/test/resolve/test-files/NodeProject/archive/package.json @@ -12,6 +12,6 @@ "express": "^4.15.2" }, "engines": { - "node": "10.0.0" + "node": "18.0.0" } } diff --git a/typings/event-stream.d.ts b/typings/event-stream.d.ts index c4497a2..6260789 100644 --- a/typings/event-stream.d.ts +++ b/typings/event-stream.d.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Stream } from 'stream'; +import type { Stream } from 'stream'; /** * Additional typing information that is merged with that available in the npm