@chuva.io/less-cli
Advanced tools
Comparing version 1.0.0-beta.14 to 1.0.0-beta.16
@@ -14,2 +14,3 @@ #!/usr/bin/env node | ||
import { verify_auth_token } from '../commands/helpers/credentials.js'; | ||
import create_custom_domain from '../commands/create_custom_domain/index.js'; | ||
@@ -22,3 +23,3 @@ const program = new Command(); | ||
.description('CLI to interact with Less') | ||
.version('1.0.0-beta.14') | ||
.version('1.0.0-beta.16') | ||
.usage('[COMMAND]'); | ||
@@ -47,2 +48,49 @@ | ||
program | ||
.command('domains') | ||
.description('Use custom domains') | ||
.option('--project-name <projectName>', 'Name of your project') | ||
.option('--static-name <staticName>', 'Name of your static folder') | ||
.option('--custom-domain <customDomain>', 'Your custom domain') | ||
.action((_, options) => { | ||
verify_auth_token(); | ||
const { | ||
projectName, | ||
staticName, | ||
customDomain | ||
} = options._optionValues; | ||
if ( | ||
!projectName || | ||
!/^[a-z][-a-z0-9]*$/.test(projectName) | ||
) { | ||
console.log(chalk.redBright('Error:'), 'The projectName must satisfy regular expression pattern: [a-z][-a-z0-9]'); | ||
process.exit(1); | ||
} | ||
if ( | ||
!staticName || | ||
!/^[a-z][-a-z0-9]*$/.test(staticName) | ||
) { | ||
console.log(chalk.redBright('Error:'), 'The staticName must satisfy regular expression pattern: [a-z][-a-z0-9]'); | ||
process.exit(1); | ||
} | ||
if ( | ||
!customDomain || | ||
!/^(?!https?:\/\/)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(customDomain) | ||
) { | ||
console.log(chalk.redBright('Error:'), 'The customDomain must satisfy regular expression pattern: (?!https?:\/\/)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'); | ||
console.log(chalk.redBright('Error:'), 'Example: example.com, subdomain.example.com, sub.subdomain.example.com'); | ||
process.exit(1); | ||
} | ||
create_custom_domain({ | ||
projectName, | ||
staticName, | ||
customDomain | ||
}); | ||
}); | ||
program | ||
.command('list') | ||
@@ -49,0 +97,0 @@ .description('List all projects.') |
@@ -85,23 +85,21 @@ import chalk from 'chalk'; | ||
// Create less/apis/demo/messages/index.js | ||
const messagesIndexPath = path.join(projectDir, 'less', 'apis', 'demo', 'messages', 'index.js'); | ||
if (!fs.existsSync(messagesIndexPath)) { | ||
const messagesIndexContent = ` | ||
const { route } = require('@chuva.io/less'); | ||
// Create less/apis/demo/messages/get.js | ||
const messagesGetPath = path.join(projectDir, 'less', 'apis', 'demo', 'messages', 'get.js'); | ||
if (!fs.existsSync(messagesGetPath)) { | ||
const messagesGetContent = ` | ||
module.exports = { | ||
get: route(async (req, res) => { | ||
process: async (request, response) => { | ||
res.body = JSON.stringify({ | ||
message: "Hello from Less demo!" | ||
}); | ||
res.statusCode = 200; | ||
return res; | ||
}, []) | ||
response.body = JSON.stringify({ | ||
message: "Hello from Less demo!" | ||
}); | ||
response.statusCode = 200; | ||
return response; | ||
} | ||
} | ||
`; | ||
fs.writeFileSync(messagesIndexPath, messagesIndexContent); | ||
fs.writeFileSync(messagesGetPath, messagesGetContent); | ||
} else { | ||
console.log(chalk.yellow('Warning:'), 'less/apis/demo/messages/index.js file already exists.'); | ||
console.log(chalk.yellow('Warning:'), 'less/apis/demo/messages/get.js file already exists.'); | ||
} | ||
@@ -108,0 +106,0 @@ |
{ | ||
"name": "@chuva.io/less-cli", | ||
"version": "1.0.0-beta.14", | ||
"version": "1.0.0-beta.16", | ||
"description": "`less-cli` is a CLI tool that allows you to deploy your Less projects to AWS while providing several other tools to facilitate your interaction with Less.", | ||
@@ -5,0 +5,0 @@ "author": "Chuva, LLC", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44759
20
870