Skip to content

Commit

Permalink
Merge pull request #60 from neon-bindings/copyArtifact
Browse files Browse the repository at this point in the history
`neon dist`: use `copyArtifact` instead of `copyFile`
  • Loading branch information
dherman authored May 19, 2024
2 parents 1de693a + 30414ad commit 379ceb7
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 93 deletions.
92 changes: 84 additions & 8 deletions dist/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40240,7 +40240,7 @@ which.sync = whichSync

/***/ }),

/***/ 3129:
/***/ 5065:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {


Expand All @@ -40256,8 +40256,6 @@ __nccwpck_require__.d(__webpack_exports__, {

;// CONCATENATED MODULE: external "node:fs"
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
// EXTERNAL MODULE: external "node:fs/promises"
var promises_ = __nccwpck_require__(3977);
// EXTERNAL MODULE: ../node_modules/command-line-args/dist/index.js
var dist = __nccwpck_require__(7898);
var dist_default = /*#__PURE__*/__nccwpck_require__.n(dist);
Expand All @@ -40270,6 +40268,11 @@ var lib = __nccwpck_require__(3993);
var manifest_lib = __nccwpck_require__(347);
// EXTERNAL MODULE: ../node_modules/@neon-rs/manifest/lib/platform.mjs
var lib_platform = __nccwpck_require__(8140);
// EXTERNAL MODULE: ../node_modules/@neon-rs/artifact/lib/index.cjs
var artifact_lib = __nccwpck_require__(8893);
;// CONCATENATED MODULE: ../node_modules/@neon-rs/artifact/lib/index.mjs


;// CONCATENATED MODULE: ./src/commands/dist.ts


Expand Down Expand Up @@ -40426,8 +40429,7 @@ class Dist {
const { option, path } = await this._out;
this.log(`output type = ${option}`);
this.log(`output file = ${path}`);
// FIXME: needs all the logic of cargo-cp-artifact (timestamp check, M1 workaround, async, errors)
await (0,promises_.copyFile)(file, path);
await (0,artifact_lib.copyArtifact)(file, path);
}
}

Expand Down Expand Up @@ -41966,6 +41968,8 @@ function execaNode(scriptPath, args, options = {}) {
);
}

// EXTERNAL MODULE: external "node:fs/promises"
var promises_ = __nccwpck_require__(3977);
;// CONCATENATED MODULE: ./src/commands/bump.ts


Expand Down Expand Up @@ -42856,7 +42860,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
/* harmony import */ var command_line_commands__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(5046);
/* harmony import */ var command_line_commands__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(command_line_commands__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _print_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(9050);
/* harmony import */ var _command_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(3129);
/* harmony import */ var _command_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(5065);
/* harmony import */ var node_module__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(2033);
/* harmony import */ var node_module__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(node_module__WEBPACK_IMPORTED_MODULE_3__);

Expand Down Expand Up @@ -45885,8 +45889,8 @@ const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});

/* harmony default export */ const chalk_source = (chalk);

// EXTERNAL MODULE: ./src/command.ts + 35 modules
var command = __nccwpck_require__(3129);
// EXTERNAL MODULE: ./src/command.ts + 36 modules
var command = __nccwpck_require__(5065);
// EXTERNAL MODULE: ./src/commands/show.ts + 4 modules
var show = __nccwpck_require__(6264);
;// CONCATENATED MODULE: ./src/print.ts
Expand Down Expand Up @@ -60868,6 +60872,78 @@ module.exports = (__nccwpck_require__(8372)/* .proxy */ .sj)({
});


/***/ }),

/***/ 8893:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.copyArtifact = exports.isNewer = void 0;
const fs = __importStar(__nccwpck_require__(3977));
const path = __importStar(__nccwpck_require__(9411));
async function isNewer(filename, outputFile) {
try {
const prevStats = await fs.stat(outputFile);
const nextStats = await fs.stat(filename);
return nextStats.mtime > prevStats.mtime;
}
catch (_err) { }
return true;
}
exports.isNewer = isNewer;
async function copyArtifact(src, dest) {
if (!(await isNewer(src, dest))) {
return;
}
const destDir = path.dirname(dest);
await fs.mkdir(destDir, { recursive: true });
// Apple Silicon (M1, etc.) requires shared libraries to be signed. However,
// the macOS code signing cache isn't cleared when overwriting a file.
// Deleting the file before copying works around the issue.
//
// Unfortunately, this workaround is incomplete because the file must be
// deleted from the location it is loaded. If further steps in the user's
// build process copy or move the file in place, the code signing cache
// will not be cleared.
//
// https://github.com/neon-bindings/neon/issues/911
if (path.extname(dest) === ".node") {
try {
await fs.unlink(dest);
}
catch (_e) {
// Ignore errors; the file might not exist
}
}
await fs.copyFile(src, dest);
}
exports.copyArtifact = copyArtifact;


/***/ }),

/***/ 9173:
Expand Down
14 changes: 7 additions & 7 deletions dist/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"homepage": "https://github.com/dherman/neon-rs#readme",
"optionalDependencies": {
"@cargo-messages/android-arm-eabi": "0.1.71",
"@cargo-messages/darwin-arm64": "0.1.71",
"@cargo-messages/darwin-x64": "0.1.71",
"@cargo-messages/linux-arm-gnueabihf": "0.1.71",
"@cargo-messages/linux-x64-gnu": "0.1.71",
"@cargo-messages/win32-arm64-msvc": "0.1.71",
"@cargo-messages/win32-x64-msvc": "0.1.71"
"@cargo-messages/android-arm-eabi": "0.1.72",
"@cargo-messages/darwin-arm64": "0.1.72",
"@cargo-messages/darwin-x64": "0.1.72",
"@cargo-messages/linux-arm-gnueabihf": "0.1.72",
"@cargo-messages/linux-x64-gnu": "0.1.72",
"@cargo-messages/win32-arm64-msvc": "0.1.72",
"@cargo-messages/win32-x64-msvc": "0.1.72"
}
}
56 changes: 28 additions & 28 deletions dist/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions src/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@neon-rs/artifact": "^0.1.0",
"@neon-rs/load": "^0.0.181",
"@neon-rs/manifest": "^0.0.5",
"cargo-messages": "^0.1.71",
"cargo-messages": "^0.1.72",
"chalk": "^5.2.0",
"command-line-args": "^5.2.1",
"command-line-commands": "^3.0.2",
Expand All @@ -69,12 +70,12 @@
"temp": "^0.9.4"
},
"optionalDependencies": {
"@cargo-messages/android-arm-eabi": "0.1.71",
"@cargo-messages/darwin-arm64": "0.1.71",
"@cargo-messages/darwin-x64": "0.1.71",
"@cargo-messages/linux-arm-gnueabihf": "0.1.71",
"@cargo-messages/linux-x64-gnu": "0.1.71",
"@cargo-messages/win32-arm64-msvc": "0.1.71",
"@cargo-messages/win32-x64-msvc": "0.1.71"
"@cargo-messages/android-arm-eabi": "0.1.72",
"@cargo-messages/darwin-arm64": "0.1.72",
"@cargo-messages/darwin-x64": "0.1.72",
"@cargo-messages/linux-arm-gnueabihf": "0.1.72",
"@cargo-messages/linux-x64-gnu": "0.1.72",
"@cargo-messages/win32-arm64-msvc": "0.1.72",
"@cargo-messages/win32-x64-msvc": "0.1.72"
}
}
5 changes: 2 additions & 3 deletions src/cli/src/commands/dist.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createReadStream } from 'node:fs';
import { copyFile } from 'node:fs/promises';
import commandLineArgs from 'command-line-args';
import { Command, CommandDetail, CommandSection } from '../command.js';
import { CargoReader } from 'cargo-messages';
import { LibraryManifest } from '@neon-rs/manifest';
import { assertIsNodePlatform } from '@neon-rs/manifest/platform';
import { copyArtifact } from '@neon-rs/artifact';

// Starting around Rust 1.78 or 1.79, cargo will begin normalizing
// crate names in the JSON output, so to support both old and new
Expand Down Expand Up @@ -180,7 +180,6 @@ export default class Dist implements Command {
this.log(`output type = ${option}`);
this.log(`output file = ${path}`);

// FIXME: needs all the logic of cargo-cp-artifact (timestamp check, M1 workaround, async, errors)
await copyFile(file, path);
await copyArtifact(file, path);
}
}
Loading

0 comments on commit 379ceb7

Please sign in to comment.