Socket
Socket
Sign inDemoInstall

@architect/create

Package Overview
Dependencies
Maintainers
6
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/create - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

9

changelog.md

@@ -5,2 +5,11 @@ # Architect Create changelog

## [4.0.2] 2022-03-02
### Fixed
- Fixed writing boilerplate files for custom runtimes (currently based on the `baseRuntime`); thanks @johncantrell97!
- Fixed incorrect banner version printing when used in a local project
---
## [4.0.1] 2022-02-25

@@ -7,0 +16,0 @@

2

package.json
{
"name": "@architect/create",
"version": "4.0.1",
"version": "4.0.2",
"description": "Idempotently initialize Architect projects",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -11,8 +11,20 @@ let chalk = require('chalk')

let ver = `Architect Create ${version}`
// Try to use the Arc version instead of create
let arcPackage = join(__dirname, '..', '..', '..', '..', 'package.json')
if (existsSync(arcPackage)) {
let pkg = JSON.parse(readFileSync(arcPackage).toString())
ver = `Architect ${pkg.version}`
let arcLocalPackage = join(__dirname, '..', '..', 'architect', 'package.json')
let arcGlobalPackage = join(__dirname, '..', '..', '..', '..', 'package.json')
let update = pkg => {
if (pkg.name === '@architect/architect') {
ver = `Architect ${pkg.version}`
}
}
if (existsSync(arcLocalPackage)) {
let pkg = JSON.parse(readFileSync(arcLocalPackage))
update(pkg)
}
else if (existsSync(arcGlobalPackage)) {
let pkg = JSON.parse(readFileSync(arcGlobalPackage))
update(pkg)
}

@@ -19,0 +31,0 @@ console.log() // Space

@@ -10,3 +10,3 @@ let { join } = require('path')

let projectRuntime = inv.aws?.runtime // What the project defaults to, if anything
let supported = getSupportedRuntimes()
let supported = getSupportedRuntimes(inventory)

@@ -13,0 +13,0 @@ // Figure out whether we have something valid to write to disk:

let { runtimes, aliases } = require('lambda-runtimes')
module.exports = function getSupportedRuntimes () {
module.exports = function getSupportedRuntimes (inventory) {
let supportedRuntimes = [ 'node', 'deno', 'ruby', 'python' ]
let { _project } = inventory.inv
if (_project.customRuntimes?.runtimes) {
supportedRuntimes.push(..._project.customRuntimes.runtimes)
}

@@ -6,0 +10,0 @@ let runtimeNames = supportedRuntimes.map(r => {

@@ -11,12 +11,11 @@ let writeTemplate = require('./write-template')

dirs.forEach(({ pragma, src }) => {
let { config, handlerFile, body } = lambdasBySrcDir[src]
let lambda = lambdasBySrcDir[src]
let template = templates?.[pragma]
if (template) {
writeTemplate({ template, handlerFile })
writeTemplate(template, lambda)
}
else {
let runtime = params.runtime || config.runtime
writeCode({ body, handlerFile, pragma, runtime })
writeCode(lambda)
}
})
}

@@ -11,14 +11,22 @@ let { sep } = require('path')

module.exports = function writeCode (params) {
let { handlerFile, pragma, runtime, body } = params
let handler = handlerFile.replace(process.cwd(), '')
module.exports = function writeCode (lambda) {
let { src, build, handlerFile, pragma, config, body } = lambda
let { runtime, runtimeConfig } = config
let filepath = handlerFile
if (handlerFile.includes(build)) {
filepath = filepath.replace(build, src)
}
let handler = filepath.replace(process.cwd(), '')
if (handler[0] === sep) handler = handler.substr(1)
runtime = aliases[runtime] ? aliases[runtime] : runtime
// TODO This is a bit hacky and needs some improvement; custom runtime plugins should write proper boilerplate code (see: `body` prop from Arc 9.x plugins)
let configuredRuntime = runtimeConfig?.baseRuntime || aliases[runtime] || runtime
let run
if (runtime.startsWith('deno')) run = 'deno'
if (runtime.startsWith('node')) run = 'node'
if (runtime.startsWith('python')) run = 'python'
if (runtime.startsWith('ruby')) run = 'ruby'
if (!run) throw ReferenceError(`Valid runtime not found: ${params.runtime}`)
if (configuredRuntime.startsWith('deno')) run = 'deno'
if (configuredRuntime.startsWith('node')) run = 'node'
if (configuredRuntime.startsWith('python')) run = 'python'
if (configuredRuntime.startsWith('ruby')) run = 'ruby'
if (!run) throw ReferenceError(`Valid runtime not found: ${configuredRuntime}`)

@@ -29,3 +37,3 @@ let types = { http, events, queues, ws, scheduled, 'tables-streams': tablesStreams, customLambdas: events }

: types[pragma][run]
writeFileSync(handlerFile, body)
writeFileSync(filepath, body)
}

@@ -5,4 +5,10 @@ let { existsSync, readFileSync, writeFileSync } = require('fs')

module.exports = function writeTemplate (params) {
let { handlerFile, template } = params
module.exports = function writeTemplate (template, lambda) {
let { src, build, handlerFile } = lambda
let filepath = handlerFile
if (handlerFile.includes(build)) {
filepath = filepath.replace(build, src)
}
let path = template[0] === '~'

@@ -15,3 +21,3 @@ ? join(homedir(), template.substr(1))

let body = readFileSync(path).toString()
writeFileSync(handlerFile, body)
writeFileSync(filepath, body)
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc