7 Commits

Author SHA1 Message Date
Marco Lipparini
cd101d6ba0 Fixing bad docker compose path 2023-07-16 05:38:10 +02:00
Marco Lipparini
48bb30dd84 Ensuring the placeholder bin doesn't get deleted during build 2023-07-16 05:28:43 +02:00
Marco Lipparini
508b3e0006 Fixing broken Yarn lifecycle hooks 2023-07-16 05:11:40 +02:00
Marco Lipparini
aefd888de3 Minor README fix 2023-07-16 04:19:33 +02:00
Marco Lipparini
577e619089 Copying binaries during "install" instead of "postinstall" 2023-07-16 04:18:22 +02:00
Marco Lipparini
2159398a3d Preparing new release 2023-07-16 03:45:59 +02:00
Marco Lipparini
1d079bdc26 Fixing broken postinstall.js 2023-07-16 03:45:24 +02:00
8 changed files with 25 additions and 29 deletions

8
.gitignore vendored
View File

@@ -1,16 +1,10 @@
bin bin/@mep-agency
build build
ldd
# misc # misc
*.log *.log
.DS_Store .DS_Store
node_modules node_modules
.cache
dist
# dependencies
/node_modules
# debug # debug
npm-debug.log* npm-debug.log*

View File

@@ -1,9 +0,0 @@
.github
build
src
*.log
.DS_Store
node_modules
.cache
*.lock

1
.prettierignore Normal file
View File

@@ -0,0 +1 @@
build

View File

@@ -52,7 +52,7 @@ Run the `ldd` binary to see the available commands:
```bash ```bash
# With Yarn # With Yarn
$ yarn ldd $ yarn ldd --help
Usage: ldd [options] [command] Usage: ldd [options] [command]
A zero-config local MariaDB instance for local development (using Docker) A zero-config local MariaDB instance for local development (using Docker)

6
bin/ldd Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
# Inspired by https://github.com/yarnpkg/yarn/issues/3421#issuecomment-1399393547
echo "This file is just a stub; it is not meant to be executed.
It will be replaced by the postinstall script with the binary for the target platform."

View File

@@ -3,10 +3,14 @@
// Inspired by: https://blog.xendit.engineer/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b // Inspired by: https://blog.xendit.engineer/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b
const fs = require('fs'); const fs = require('fs');
const path = require('path');
const BIN_BASE_NAME = './bin/@mep-agency/local-dev-db'; const BIN_BASE_DIR = `${__dirname}/bin`;
const BIN_OUTPUT_PATH = `${BIN_BASE_DIR}/ldd`;
const BIN_OPTIONS_DIR = `${BIN_BASE_DIR}/@mep-agency`;
const BIN_OPTIONS_BASE_NAME = `${BIN_OPTIONS_DIR}/local-dev-db`;
if (!fs.existsSync(BIN_BASE_NAME) || !fs.statSync(BIN_BASE_NAME).isDirectory()) { if (!fs.existsSync(BIN_OPTIONS_DIR) || !fs.statSync(BIN_OPTIONS_DIR).isDirectory()) {
console.info('Binaries are not available, this probably means we are in a development environment... skipping!'); console.info('Binaries are not available, this probably means we are in a development environment... skipping!');
process.exit(0); process.exit(0);
@@ -22,7 +26,7 @@ const PLATFORM_MAPPING = {
win32: 'win.exe', win32: 'win.exe',
}; };
async function install(callback) { async function postinstall(callback) {
if (PLATFORM_MAPPING[process.platform] === undefined) { if (PLATFORM_MAPPING[process.platform] === undefined) {
callback(`Unsupported platform: "${process.platform}"`); callback(`Unsupported platform: "${process.platform}"`);
} }
@@ -31,20 +35,20 @@ async function install(callback) {
callback(`Unsupported architecture: "${process.arch}"`); callback(`Unsupported architecture: "${process.arch}"`);
} }
const binaryNameTokens = [BIN_BASE_NAME, PLATFORM_MAPPING[process.platform], ARCH_MAPPING[process.arch]].filter( const binaryNameTokens = [BIN_OPTIONS_BASE_NAME, PLATFORM_MAPPING[process.platform], ARCH_MAPPING[process.arch]].filter(
(token) => token.length > 0, (token) => token.length > 0,
); );
console.info(`Copying the relevant binary for your platform ${process.platform} (${process.arch})`); console.info(`Copying the relevant binary for your platform ${process.platform} (${process.arch})`);
fs.copyFileSync(binaryNameTokens.join('-'), './ldd'); fs.copyFileSync(binaryNameTokens.join('-'), BIN_OUTPUT_PATH);
callback(null); callback(null);
} }
// Parse command line arguments and call the right method // Parse command line arguments and call the right method
var actions = { var actions = {
install: install, postinstall: postinstall,
}; };
const argv = process.argv; const argv = process.argv;

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mep-agency/local-dev-db", "name": "@mep-agency/local-dev-db",
"version": "1.0.0-alpha2", "version": "1.0.0-alpha7",
"private": false, "private": false,
"description": "A zero-config local MariaDB instance for local development (using Docker)", "description": "A zero-config local MariaDB instance for local development (using Docker)",
"author": "Marco Lipparini <developer@liarco.net>", "author": "Marco Lipparini <developer@liarco.net>",
@@ -21,19 +21,19 @@
"url": "https://github.com/mep-agency/local-dev-db/issues" "url": "https://github.com/mep-agency/local-dev-db/issues"
}, },
"scripts": { "scripts": {
"build": "rm -rf ./bin && rm -rf ./build && tsc && pkg -c package.json ./build/src/index.js && yarn postinstall", "build": "rm -rf ./bin/@mep-agency && rm -rf ./build && tsc && pkg -c package.json ./build/src/index.js",
"watch": "tsc --watch", "watch": "tsc --watch",
"format": "prettier --write \"**/*.{ts,md,scss,css,js}\"", "format": "prettier --write \"**/*.{ts,md,scss,css,js}\"",
"lint": "prettier --check \"**/*.{ts,md,scss,css,js}\"", "lint": "prettier --check \"**/*.{ts,md,scss,css,js}\"",
"postinstall": "node postinstall.js install" "postinstall": "node lifecycle.js postinstall"
}, },
"bin": { "bin": {
"ldd": "./ldd" "ldd": "./bin/ldd"
}, },
"files": [ "files": [
"bin", "bin",
"docker", "docker",
"postinstall.js", "lifecycle.js",
"LICENCE", "LICENCE",
"README.md" "README.md"
], ],

View File

@@ -8,7 +8,7 @@ import mysql from 'mysql';
import packageInfo from '../package.json'; import packageInfo from '../package.json';
let PACKAGE_INSTALLATION_PATH = path.normalize( let PACKAGE_INSTALLATION_PATH = path.normalize(
__dirname.startsWith('/snapshot') ? path.dirname(process.execPath) : `${__dirname}/../..`, __dirname.startsWith('/snapshot') ? `${path.dirname(process.execPath)}/..` : `${__dirname}/../..`,
); );
const dockerCompose: typeof dockerCommand = async (command, options) => { const dockerCompose: typeof dockerCommand = async (command, options) => {