release-it-docker-plugin 0.0.0 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of release-it-docker-plugin might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,26 +1,24 @@
1
1
  {
2
2
  "name": "release-it-docker-plugin",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": "",
7
7
  "homepage": "",
8
8
  "author": "Raiper34",
9
9
  "license": "MIT",
10
- "main": "dist/index.js",
11
- "types": "dist/index.d.ts",
10
+ "main": "src/index.js",
11
+ "type": "module",
12
12
  "scripts": {
13
13
  "build": "npx tsc"
14
14
  },
15
15
  "devDependencies": {
16
- "release-it": "^18.1.1",
17
- "typescript": "^5.6.3"
16
+ "release-it": "^18.1.1"
18
17
  },
19
18
  "peerDependencies": {
20
19
  "release-it": "^18.1.1"
21
20
  },
22
21
  "dependencies": {
23
- "@types/lodash": "^4.17.14",
24
22
  "lodash": "^4.17.21"
25
23
  }
26
24
  }
@@ -3,18 +3,7 @@ import _ from 'lodash';
3
3
 
4
4
  // I was unable to import plugin class from release-it v18, so I copied and pasted it here and typed a bit for my use case.
5
5
  // See: https://github.com/release-it/release-it/blob/main/lib/plugin/Plugin.js
6
- export class BasePlugin {
7
-
8
- namespace: any;
9
- options: any;
10
- context: any;
11
- config: any;
12
- log: any;
13
- shell: any;
14
- spinner: any;
15
- prompt: any;
16
- debug: any;
17
-
6
+ class Plugin {
18
7
  static isEnabled() {
19
8
  return true;
20
9
  }
@@ -23,7 +12,7 @@ export class BasePlugin {
23
12
  return null;
24
13
  }
25
14
 
26
- constructor({ namespace, options = {}, container = {} }: any = {}) {
15
+ constructor({ namespace, options = {}, container = {} } = {}) {
27
16
  this.namespace = namespace;
28
17
  this.options = Object.freeze(this.getInitialOptions(options, namespace));
29
18
  this.context = {};
@@ -35,7 +24,7 @@ export class BasePlugin {
35
24
  this.debug = debug(`release-it:${namespace}`);
36
25
  }
37
26
 
38
- getInitialOptions(options: any, namespace: any) {
27
+ getInitialOptions(options, namespace) {
39
28
  return options[namespace] || {};
40
29
  }
41
30
 
@@ -48,34 +37,34 @@ export class BasePlugin {
48
37
  getIncrementedVersion() {}
49
38
  beforeBump() {}
50
39
  bump() {}
51
- beforeRelease(version: any) {}
52
- release(version: any) {}
40
+ beforeRelease() {}
41
+ release() {}
53
42
  afterRelease() {}
54
43
 
55
- getContext(path?: any): any {
44
+ getContext(path) {
56
45
  const context = _.merge({}, this.options, this.context);
57
46
  return path ? _.get(context, path) : context;
58
47
  }
59
48
 
60
- setContext(context: any) {
49
+ setContext(context) {
61
50
  _.merge(this.context, context);
62
51
  }
63
52
 
64
- exec(command: any, { options, context = {} }: any = {}) {
53
+ exec(command, { options, context = {} } = {}) {
65
54
  const ctx = Object.assign(context, this.config.getContext(), { [this.namespace]: this.getContext() });
66
55
  return this.shell.exec(command, options, ctx);
67
56
  }
68
57
 
69
- registerPrompts(prompts: any) {
58
+ registerPrompts(prompts) {
70
59
  this.prompt.register(prompts, this.namespace);
71
60
  }
72
61
 
73
- async showPrompt(options: any) {
62
+ async showPrompt(options) {
74
63
  options.namespace = this.namespace;
75
64
  return this.prompt.show(options);
76
65
  }
77
66
 
78
- step(options: any) {
67
+ step(options) {
79
68
  const context = Object.assign({}, this.config.getContext(), { [this.namespace]: this.getContext() });
80
69
  const opts = Object.assign({}, options, { context });
81
70
  const isException = this.config.isPromptOnlyVersion && ['incrementList', 'publish', 'otp'].includes(opts.prompt);
@@ -2,7 +2,7 @@ import {BasePlugin} from "./base-plugin";
2
2
 
3
3
  const DOCKER_HUB_BASE_URL = 'https://hub.docker.com';
4
4
 
5
- export default class DockerPlugin extends BasePlugin{
5
+ export default class DockerPlugin extends BasePlugin {
6
6
 
7
7
  async beforeRelease() {
8
8
  if (this.options.build === false) return false;
@@ -21,7 +21,7 @@ export default class DockerPlugin extends BasePlugin{
21
21
  }
22
22
  }
23
23
 
24
- private build() {
24
+ build() {
25
25
  const { imageName, latestTag } = this.options;
26
26
  const args = [
27
27
  '-t', `${imageName}:${this.getContext().version}`,
@@ -29,21 +29,21 @@ export default class DockerPlugin extends BasePlugin{
29
29
  ];
30
30
  return this.exec(`docker build ${args.filter(Boolean).join(' ')} .`).then(
31
31
  () => this.setContext({ isBuilt: true }),
32
- (err: any) => {
32
+ (err) => {
33
33
  this.debug(err);
34
34
  throw new Error(err);
35
35
  }
36
36
  );
37
37
  }
38
38
 
39
- private publish() {
39
+ publish() {
40
40
  const { imageName, latestTag } = this.options;
41
41
  return Promise.all([
42
42
  this.exec(`docker push ${imageName}:${this.getContext().version}`),
43
43
  latestTag ? this.exec(`docker push ${imageName}:latest`) : Promise.resolve(),
44
44
  ]).then(
45
45
  () => this.setContext({ isPublished: true }),
46
- (err: any) => {
46
+ (err) => {
47
47
  this.debug(err);
48
48
  throw new Error(err);
49
49
  }
@@ -1,34 +0,0 @@
1
- export declare class BasePlugin {
2
- namespace: any;
3
- options: any;
4
- context: any;
5
- config: any;
6
- log: any;
7
- shell: any;
8
- spinner: any;
9
- prompt: any;
10
- debug: any;
11
- static isEnabled(): boolean;
12
- static disablePlugin(): null;
13
- constructor({ namespace, options, container }?: any);
14
- getInitialOptions(options: any, namespace: any): any;
15
- init(): void;
16
- getName(): void;
17
- getLatestVersion(): void;
18
- getChangelog(): void;
19
- getIncrement(): void;
20
- getIncrementedVersionCI(): void;
21
- getIncrementedVersion(): void;
22
- beforeBump(): void;
23
- bump(): void;
24
- beforeRelease(version: any): void;
25
- release(version: any): void;
26
- afterRelease(): void;
27
- getContext(path?: any): any;
28
- setContext(context: any): void;
29
- exec(command: any, { options, context }?: any): any;
30
- registerPrompts(prompts: any): void;
31
- showPrompt(options: any): Promise<any>;
32
- step(options: any): any;
33
- }
34
- export default Plugin;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BasePlugin = void 0;
16
- const node_util_1 = require("node:util");
17
- const lodash_1 = __importDefault(require("lodash"));
18
- // I was unable to import plugin class from release-it v18, so I copied and pasted it here and typed a bit for my use case.
19
- // See: https://github.com/release-it/release-it/blob/main/lib/plugin/Plugin.js
20
- class BasePlugin {
21
- static isEnabled() {
22
- return true;
23
- }
24
- static disablePlugin() {
25
- return null;
26
- }
27
- constructor({ namespace, options = {}, container = {} } = {}) {
28
- this.namespace = namespace;
29
- this.options = Object.freeze(this.getInitialOptions(options, namespace));
30
- this.context = {};
31
- this.config = container.config;
32
- this.log = container.log;
33
- this.shell = container.shell;
34
- this.spinner = container.spinner;
35
- this.prompt = container.prompt;
36
- this.debug = (0, node_util_1.debug)(`release-it:${namespace}`);
37
- }
38
- getInitialOptions(options, namespace) {
39
- return options[namespace] || {};
40
- }
41
- init() { }
42
- getName() { }
43
- getLatestVersion() { }
44
- getChangelog() { }
45
- getIncrement() { }
46
- getIncrementedVersionCI() { }
47
- getIncrementedVersion() { }
48
- beforeBump() { }
49
- bump() { }
50
- beforeRelease(version) { }
51
- release(version) { }
52
- afterRelease() { }
53
- getContext(path) {
54
- const context = lodash_1.default.merge({}, this.options, this.context);
55
- return path ? lodash_1.default.get(context, path) : context;
56
- }
57
- setContext(context) {
58
- lodash_1.default.merge(this.context, context);
59
- }
60
- exec(command, { options, context = {} } = {}) {
61
- const ctx = Object.assign(context, this.config.getContext(), { [this.namespace]: this.getContext() });
62
- return this.shell.exec(command, options, ctx);
63
- }
64
- registerPrompts(prompts) {
65
- this.prompt.register(prompts, this.namespace);
66
- }
67
- showPrompt(options) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- options.namespace = this.namespace;
70
- return this.prompt.show(options);
71
- });
72
- }
73
- step(options) {
74
- const context = Object.assign({}, this.config.getContext(), { [this.namespace]: this.getContext() });
75
- const opts = Object.assign({}, options, { context });
76
- const isException = this.config.isPromptOnlyVersion && ['incrementList', 'publish', 'otp'].includes(opts.prompt);
77
- return this.config.isCI && !isException ? this.spinner.show(opts) : this.showPrompt(opts);
78
- }
79
- }
80
- exports.BasePlugin = BasePlugin;
81
- exports.default = Plugin;
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { BasePlugin } from "./base-plugin";
2
- export default class DockerPlugin extends BasePlugin {
3
- beforeRelease(): Promise<any>;
4
- release(): Promise<any>;
5
- afterRelease(): void;
6
- private build;
7
- private publish;
8
- }
package/dist/index.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const base_plugin_1 = require("./base-plugin");
13
- const DOCKER_HUB_BASE_URL = 'https://hub.docker.com';
14
- class DockerPlugin extends base_plugin_1.BasePlugin {
15
- beforeRelease() {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- if (this.options.build === false)
18
- return false;
19
- return this.step({ task: () => this.build(), label: 'docker build', prompt: { message: 'Build?', default: this.options.build } });
20
- });
21
- }
22
- release() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- if (this.options.publish === false)
25
- return false;
26
- return this.step({ task: () => this.publish(), label: 'docker publish', prompt: { message: 'Publish?', default: this.options.publish } });
27
- });
28
- }
29
- afterRelease() {
30
- const { isPublished } = this.getContext();
31
- if (isPublished) {
32
- this.log.log(`🔗 ${DOCKER_HUB_BASE_URL}/r/${this.options.imageName}`);
33
- }
34
- }
35
- build() {
36
- const { imageName, latestTag } = this.options;
37
- const args = [
38
- '-t', `${imageName}:${this.getContext().version}`,
39
- ...(latestTag ? ['-t', `${imageName}:latest`] : [])
40
- ];
41
- return this.exec(`docker build ${args.filter(Boolean).join(' ')} .`).then(() => this.setContext({ isBuilt: true }), (err) => {
42
- this.debug(err);
43
- throw new Error(err);
44
- });
45
- }
46
- publish() {
47
- const { imageName, latestTag } = this.options;
48
- return Promise.all([
49
- this.exec(`docker push ${imageName}:${this.getContext().version}`),
50
- latestTag ? this.exec(`docker push ${imageName}:latest`) : Promise.resolve(),
51
- ]).then(() => this.setContext({ isPublished: true }), (err) => {
52
- this.debug(err);
53
- throw new Error(err);
54
- });
55
- }
56
- }
57
- exports.default = DockerPlugin;
package/tsconfig.json DELETED
@@ -1,102 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Enable incremental compilation */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- // "jsx": "preserve", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
-
26
- /* Modules */
27
- "module": "commonjs", /* Specify what module code is generated. */
28
- // "rootDir": "./", /* Specify the root folder within your source files. */
29
- // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
33
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
34
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
35
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36
- // "resolveJsonModule": true, /* Enable importing .json files */
37
- // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
38
-
39
- /* JavaScript Support */
40
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
41
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
42
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
43
-
44
- /* Emit */
45
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
46
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
47
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
48
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
49
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
50
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
51
- // "removeComments": true, /* Disable emitting comments. */
52
- // "noEmit": true, /* Disable emitting files from a compilation. */
53
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
54
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
55
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
56
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
57
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
60
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
61
- // "newLine": "crlf", /* Set the newline character for emitting files. */
62
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
63
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
64
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
65
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
66
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
67
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
68
-
69
- /* Interop Constraints */
70
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
71
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
72
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
73
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
74
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
75
-
76
- /* Type Checking */
77
- "strict": true, /* Enable all strict type-checking options. */
78
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
79
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
80
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
81
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
82
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
83
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
84
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
85
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
86
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
87
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
88
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
89
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
90
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
91
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
92
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
93
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
94
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
95
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
96
-
97
- /* Completeness */
98
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
99
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
100
- },
101
- "include": ["src"]
102
- }