Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve overrides from root package #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/actions/autoinstall/get-root-params.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let { existsSync, readFileSync } = require('fs')
let { join } = require('path')

// Get params from root project that should be preserved in hydrated package.json
module.exports = function getRootParams ({ inv }) {
let root = inv._project.cwd
let packageJson = join(root, 'package.json')

let package = existsSync(packageJson) && JSON.parse(readFileSync(packageJson)) || {}

let result = {}
if (package.overrides)
result.overrides = package.overrides

return result
}
4 changes: 3 additions & 1 deletion src/actions/autoinstall/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let { existsSync, renameSync, writeFileSync } = require('fs')
let { join } = require('path')
let getRootDeps = require('./get-root-deps')
let getRootParams = require('./get-root-params')
let getSharedDeps = require('./get-shared-deps')
let getLambdaDeps = require('./get-lambda-deps')

Expand Down Expand Up @@ -68,12 +69,13 @@ module.exports = function autoinstaller (params) {
_parsed: files.sort(),
description: `This file was generated by Architect, and placed in node_modules to aid in debugging; if you found file in your function directory, you can safely remove it (and package-lock.json)`,
dependencies,
...getRootParams(inventory)
}
let params = {
dir,
file: 'package.json',
remove: [ 'package.json', 'package-lock.json' ], // Identify files for later removal
data: JSON.stringify(lambdaPackage, null, 2)
data: JSON.stringify(lambdaPackage, null, 2),
}
// Autoinstall can be called on a directory that contains a package.json with `"type": "module"` (and no dependencies)
// If we find such a case, kindly move the existing package.json aside until autoinstall ops are complete
Expand Down