Skip to content

Commit ceca53e

Browse files
authored
feat: esm-only, drop bluebird, shelljs, yarn (#64)
BREAKING CHANGE: drops usage of mentioned dependencies, only distributes as ESM. Introduces cosmicconfig to be able to read more configuration formats. This can still be used in CJS project as it is self-contained. However, projects using chrome helpers may have issues, auto-install script does less and eventually should be fully removed. Now accepts uid for test / exec user, resolves it or creates user with that uid and uses it going forward
1 parent 6c197e6 commit ceca53e

34 files changed

+2566
-4275
lines changed
File renamed without changes.

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"extends": "makeomatic",
3+
"parserOptions": {
4+
"ecmaVersion": "latest"
5+
},
36
"rules": {
47
"no-unused-expressions": 0,
5-
"object-curly-newline": 0
8+
"object-curly-newline": 0,
9+
"import/extensions": ["error", "always", { "ignorePackages": true }],
10+
"no-console": 0
611
}
712
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ ss/*.jpeg
4040

4141
# IDEs
4242
.idea
43+
.pnpm-store

.mdeprc.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* eslint-disable no-template-curly-in-string */
2+
import { userInfo } from 'node:os';
23

3-
module.exports = {
4-
nycCoverage: false,
5-
test_framework: 'jest --coverage --coverageDirectory <coverageDirectory> --runTestsByPath --maxWorkers=50% --colors',
4+
const { uid } = userInfo();
5+
6+
export default {
7+
test_framework: 'c8 node --test',
68
tests: '__tests__/*.js',
79
auto_compose: true,
8-
node: '18',
10+
node: '20.10',
911
tester_flavour: 'chrome-tester',
10-
mirror: process.platform !== 'darwin',
1112
services: [
1213
'redisSentinel',
1314
'redisCluster',
@@ -29,7 +30,12 @@ module.exports = {
2930
},
3031
},
3132
},
32-
euser: 'root',
33-
tuser: 'node',
34-
arbitrary_exec: ['apk add git'],
33+
euser: 0,
34+
tuser: uid,
35+
arbitrary_exec: [
36+
'apk add git',
37+
process.env.flavour === 'http'
38+
? ['/bin/sh', '-c', `addgroup $(getent passwd ${uid} | cut -d: -f1) node`] // child_process.exec
39+
: ['addgroup', `$(getent passwd ${uid} | cut -d: -f1)`, 'node'], // docker exec /bin/sh -c "<command>"
40+
],
3541
};

.semaphore/semaphore.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ global_job_config:
1717
prologue:
1818
commands:
1919
- set -e
20-
- sem-version node 18
21-
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@8
20+
- sem-version node 20.10
21+
- corepack enable
22+
- corepack install --global pnpm@8.x
2223
- checkout
2324
- cache restore node-$(checksum pnpm-lock.yaml)
2425
- pnpm i --prefer-offline
25-
- cache store node-$(checksum pnpm-lock.yaml) ~/.pnpm-store
26+
- cache store node-$(checksum pnpm-lock.yaml) $(pnpm store path)
2627

2728
blocks:
2829
- name: tests

README.md

Lines changed: 100 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,12 @@
11
# Makeomatic deploy tools
22

33
Provides convenient deploy tools, which automate publishing of docker images, documentation & testing
4+
ESM-only now
45

56
## Install
67

78
`npm i @makeomatic/deploy -D`
89

9-
## Utility functions
10-
11-
```js
12-
const Promise = require('bluebird');
13-
const { inspectPromise } = require('@makeomatic/deploy');
14-
15-
// simple test cases that illustrate inspectPromise utility
16-
describe('Promise verification', () => {
17-
it('rejects request', () => {
18-
return Promise
19-
.reject(new Error('some great error'))
20-
.reflect()
21-
.then(inspectPromise(false))
22-
.then((err) => {
23-
assert.equal(err.message, 'some great error');
24-
return null;
25-
});
26-
});
27-
28-
it('promise does not reject', () => {
29-
return Promise
30-
.resolve('banana')
31-
.reflect()
32-
.then(inspectPromise())
33-
.then((response) => {
34-
assert.equal(response, 'banana');
35-
return null;
36-
});
37-
});
38-
});
39-
```
40-
4110
## Cli
4211

4312
```bash
@@ -60,27 +29,39 @@ Options:
6029
```bash
6130
bin/cli.js docker
6231

32+
manages docker lifecycle
33+
6334
Commands:
64-
build builds docker image for a project
65-
push pushes previously build docker images
66-
release performs build, tagging and push in one operation
67-
tag tags built docker image
35+
cli.mjs docker build builds docker image for a project
36+
cli.mjs docker push pushes previously build docker images
37+
cli.mjs docker release performs build, tagging and push in one operation
38+
cli.mjs docker tag tags built docker image
6839

6940
Options:
70-
--node, -n node version to use when building [default: "7.8.0"]
71-
--env, -E node environment to build for [default: "production"]
72-
--project, -p project name where this is used
73-
[default: "makeomatic-deploy"]
74-
--version, -v version of the project to build [default: "1.5.0"]
75-
--pkg package json path
76-
[default: "/Users/vitaly/projects/makeomatic-deploy/package.json"]
77-
--help Show help [boolean]
78-
--repository, --repo docker repository to use [default: "makeomatic"]
79-
--include_node, --in includes node version in the tag
41+
-n, --node node version to use when building
42+
[string] [default: "20"]
43+
-E, --env node environment to build for
44+
[default: "production"]
45+
-p, --project project name where this is used
46+
[default: "deploy"]
47+
--docker_build_args, --dba docker build args
48+
--docker_flags, --df docker build flags [array]
49+
--repository, --repo docker repository to use
50+
[default: "makeomatic"]
51+
-v, --version version of the project to build
52+
[default: "0.0.0-development"]
53+
--pkg package json path
54+
[default: "/Users/vitaly/projects/@makeomatic/deploy/package.json"]
55+
--include_node, --in includes node version in the tag
8056
[boolean] [default: true]
81-
--docker_file, -f path to docker file [string] [default: "./Dockerfile"]
82-
--extra_tags, -T list of additional tags for the image
57+
--tag_latest, --tl adds :latest tag to the image
58+
[boolean] [default: false]
59+
-f, --docker_file path to docker file
60+
[string] [default: "./Dockerfile"]
61+
-T, --extra_tags list of additional tags for the image
8362
[array] [default: []]
63+
-c, --docker_context docker build context path [default: "."]
64+
--help Show help [boolean]
8465
```
8566
8667
## Test
@@ -91,61 +72,91 @@ cli.js test <command>
9172
performs tests in docker
9273

9374
Commands:
94-
cli.js test auto-compose prepares docker-compose file based on config
95-
cli.js test compose installs compose on the system
96-
cli.js test init adds basic files for testing
97-
cli.js test run performs testing
75+
cli.mjs test compose prepares docker-compose file based on config
76+
cli.mjs test compose installs compose on the system
77+
cli.mjs test run performs testing
9878

9979
Options:
100-
--node, -n node version to use when building
101-
[default: "9.3.0"]
102-
--env, -E node environment to build for
80+
-n, --node node version to use when building
81+
[string] [default: "20"]
82+
-E, --env node environment to build for
10383
[default: "production"]
104-
--project, -p project name where this is used
84+
-p, --project project name where this is used
10585
[default: "deploy"]
106-
--repository, --repo docker repository to use
86+
--docker_build_args, --dba docker build args
87+
--docker_flags, --df docker build flags [array]
88+
--repository, --repo docker repository to use
10789
[default: "makeomatic"]
108-
--version, -v version of the project to build
90+
-v, --version version of the project to build
10991
[default: "0.0.0-development"]
110-
--pkg package json path
92+
--pkg package json path
11193
[default: "/Users/vitaly/projects/@makeomatic/deploy/package.json"]
112-
--docker_compose docker-compose file for testing
94+
--docker_compose docker-compose file for testing
11395
[string] [default: "./test/docker-compose.yml"]
114-
--auto_compose [boolean] [default: false]
115-
--tester_flavour [string] [default: "tester"]
116-
--extras any extras for tester docker container, will
117-
be merged [string] [default: {}]
118-
--services enable listed services
119-
[array] [choices: "redis", "redisCluster", "redisSentinel", "postgres",
120-
"rabbitmq"]
121-
--docker_compose_version, --dcv docker-compose version to use
96+
--docker_compose_multi, --dcm docker-compose files that will be started
97+
in provided order [array] [default: []]
98+
--parallel run test suites in parallel
99+
[number] [default: 1]
100+
-s, --sort sort tests in alphabetical order and run
101+
sequentially. disables `parallel` mode
102+
[boolean] [default: false]
103+
--auto_compose [boolean] [default: false]
104+
--auto_compose_version, --acv [string] [default: "3"]
105+
--with_local_compose also include services defined in the dock
106+
er_compose file. Senseless w/o auto_compo
107+
se=true [boolean] [default: false]
108+
--tester_flavour [string] [default: "tester"]
109+
--extras any extras for tester docker container, w
110+
ill be merged [string] [default: {}]
111+
--services enable listed services
112+
[array] [choices: "redis", "redisCluster", "redisSentinel", "postgres", "rabbi
113+
tmq", "elasticsearch", "cassandra", "couchdb"]
114+
--docker_compose_version, --dcv docker-compose version to use
122115
[default: "1.11.2"]
123-
--docker_compose_force, --dcf forces to install local copy of
124-
docker-compose in case of version mismatch
116+
--docker_compose_force, --dcf forces to install local copy of docker-co
117+
mpose in case of version mismatch
125118
[boolean] [default: false]
126-
--tests, -t glob for test files
119+
-t, --tests glob for test files
127120
[string] [default: "./test/suites/**/*.js"]
128-
--no_cleanup, -C cleanup automatically
121+
-C, --no_cleanup cleanup automatically
129122
[boolean] [default: false]
130-
--wait_before_tests, --sleep how much time to wait after docker-compose up
131-
[number] [default: 0]
132-
--report_dir report dir for coverage
123+
--wait_before_tests, --sleep how much time to wait after docker-compos
124+
e up [number] [default: 0]
125+
--report_dir report dir for coverage
133126
[default: "./coverage"]
134-
--test_framework test framework to use [default: "mocha"]
135-
--coverage whether to upload coverage or not
136-
[boolean] [default: false]
137-
--root binary root path on the tester
127+
--test_framework test framework to use [default: "mocha"]
128+
--root binary root path on the tester
138129
[default: "/src/node_modules/.bin"]
139-
--rebuild, -r list modules to rebuild during testing
130+
-r, --rebuild list modules to rebuild during testing
140131
[array] [default: []]
141-
--on_fail, --fail arbitrary code to execute on test failure
142-
--custom_run custom run command for the tests
143-
--gyp run nody-gyp-rebuild before tests
132+
--on_fail, --fail arbitrary code to execute on test failure
133+
--custom_run custom run command for the tests
134+
--gyp run nody-gyp-rebuild before tests
144135
[boolean] [default: false]
145-
--arbitrary_exec arbitrary commands to exec in docker tester
146-
[array] [default: []]
147-
--pre pre commands to run [array] [default: []]
148-
--nycCoverage set to --no-nycCoverage to disable it
149-
[boolean] [default: true]
150-
--help Show help [boolean]
136+
--arbitrary_exec arbitrary commands to exec in docker test
137+
er [array] [default: []]
138+
--pre pre commands to run [array] [default: []]
139+
--test_args extra arguments for test framework
140+
[string] [default: ""]
141+
--pull force pull docker containers
142+
[boolean] [default: false]
143+
--post_exec commands to exec in docker tester after a
144+
ll tests finished [array] [default: []]
145+
--http uses http exec instead of docker exec to
146+
run tests [boolean] [default: false]
147+
--mutagen-dir custom mutagen dir
148+
[default: "/Users/vitaly/projects/@makeomatic/deploy"]
149+
--mutagen-working-dir custom mutagen working dir
150+
--mutagen-volume-name shared mutagen volume name
151+
[string] [default: "makeomatic-deploy-code"]
152+
--mutagen-volume-external set as external to avoid recreating each
153+
time [boolean] [default: false]
154+
--exec-user, --euser user to run setup commands with [number]
155+
--test-user, --tuser user to run test commands with [number]
156+
--in-one, --in_one runs all tests in 1 test runner
157+
[boolean] [default: false]
158+
--env-file, --env_file .env file for docker-compose [string]
159+
--only-prepare creates containers but doesn't run the te
160+
sts [boolean] [default: false]
161+
--help Show help [boolean]
151162
```

__tests__/bin.chrome.spec.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
const Promise = require('bluebird');
1+
import test, { describe, after } from 'node:test';
2+
import assert from 'node:assert/strict';
3+
import Chrome, { captureScreenshot } from '../bin/chrome.js';
24

35
describe('chrome helpers', () => {
4-
const Chrome = require('../bin/chrome');
56
let chrome;
67

7-
it('launches chrome', async () => {
8+
test('launches chrome', async () => {
89
const connection = await Chrome();
9-
expect(connection.launcher).toBeDefined();
10-
expect(connection.protocol).toBeDefined();
11-
expect(connection.close).toBeDefined();
10+
assert(connection.launcher);
11+
assert(connection.protocol);
12+
assert(connection.close);
1213
chrome = connection;
1314
});
1415

15-
it('renders facebook', async () => {
16+
test('renders facebook', async () => {
1617
const context = chrome;
1718
const { Page } = context.protocol;
1819

1920
Page.navigate({ url: 'https://facebook.com' });
2021
await Page.loadEventFired();
21-
await Promise.bind(context).then(Chrome.captureScreenshot);
22+
await captureScreenshot.call(context);
2223
}, 10000);
2324

24-
afterAll(async () => (
25+
after(async () => (
2526
chrome ? chrome.close() : null
2627
));
2728
});

0 commit comments

Comments
 (0)