Socket
Socket
Sign inDemoInstall

create-dynamic-app

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-dynamic-app - npm Package Compare versions

Comparing version 0.1.1 to 0.1.6

.babelrc

157

index.js

@@ -13,81 +13,108 @@ #!/usr/bin/env node

async function askFrameworkQuestion() {
const frameworkQuestion = [
{
type: 'list',
name: 'framework',
message: 'What framework would you like to use?',
choices: [
{ name: 'NextJS', value: 'nextjs' },
{ name: 'ReactJS', value: 'react' },
{ name: 'React Native', value: 'react-native' }
],
}
];
return inquirer.prompt(frameworkQuestion);
}
const questions = [
{
type: 'list',
name: 'framework',
message: 'What framework would you like to use?',
choices: [
{ name: 'NextJS', value: 'nextjs' },
{ name: 'ReactJS', value: 'react' }
],
},
{
type: 'list',
name: 'library',
message: 'Are you happy with Viem, or do you need Ethers?',
choices: [
{ name: 'Happy with Viem', value: 'viem' },
{ name: 'I need Ethers', value: 'ethers' }
]
},
{
type: 'list',
name: 'wagmi',
message: 'Do you want to use Wagmi on top of Dynamic?',
choices: [
{ name: 'Yes', value: 'wagmi' },
{ name: 'No', value: '' }
]
async function askAdditionalQuestions(answers) {
if (answers.framework === 'react-native') {
return answers;
}
];
async function checkDirectoryExists(directory) {
try {
await fs.access(directory);
return true;
} catch (error) {
return false;
const additionalQuestions = [
{
type: 'list',
name: 'library',
message: 'Are you happy with Viem, or do you need Ethers?',
choices: [
{ name: 'Happy with Viem', value: 'viem' },
{ name: 'I need Ethers', value: 'ethers' }
]
},
{
type: 'list',
name: 'wagmi',
message: 'Do you want to use Wagmi on top of Dynamic?',
choices: [
{ name: 'Yes', value: 'wagmi' },
{ name: 'No', value: '' }
]
}
];
const additionalAnswers = await inquirer.prompt(additionalQuestions);
return { ...answers, ...additionalAnswers };
}
async function checkDirectoryExists(directory) {
try {
await fs.access(directory);
return true;
} catch (error) {
return false;
}
}
async function cloneRepository(repoUrl, directoryName) {
try {
await simpleGit().clone(repoUrl, directoryName);
console.log(chalk.green('Project setup complete! Check it out in the', directoryName, 'directory, and run "npm i" to get started.'));
} catch (error) {
console.error(chalk.red('Failed to clone the repository:', error));
}
try {
await simpleGit().clone(repoUrl, directoryName);
console.log(chalk.green('Project setup complete! Check it out in the', directoryName, 'directory, and run "npm i" to get started.'));
} catch (error) {
console.error(chalk.red('Failed to clone the repository:', error));
}
}
async function askForNewDirectory(originalDirectory, repoUrl) {
const answer = await inquirer.prompt({
type: 'input',
name: 'newDirectory',
message: `The directory "${originalDirectory}" already exists. Enter a new directory name:`,
validate: input => input ? true : 'Please enter a valid directory name.'
});
const newDir = answer.newDirectory;
const directoryExists = await checkDirectoryExists(newDir);
if (directoryExists) {
await askForNewDirectory(newDir, repoUrl); // Pass repoUrl to keep it in scope
} else {
await cloneRepository(repoUrl, newDir);
}
const answer = await inquirer.prompt({
type: 'input',
name: 'newDirectory',
message: `The directory "${originalDirectory}" already exists. Enter a new directory name:`,
validate: input => input ? true : 'Please enter a valid directory name.'
});
const newDir = answer.newDirectory;
const directoryExists = await checkDirectoryExists(newDir);
if (directoryExists) {
await askForNewDirectory(newDir, repoUrl);
} else {
await cloneRepository(repoUrl, newDir);
}
}
async function main() {
const answers = await inquirer.prompt(questions);
const repoUrl = `https://github.com/dynamic-labs/${answers.framework}-${answers.library}${answers.wagmi ? '-' + answers.wagmi : ''}`;
const directoryName = process.argv[2] || 'my-dynamic-project';
const directoryExists = await checkDirectoryExists(directoryName);
export function generateRepoUrl(answers) {
if (answers.framework === 'react-native') return `https://github.com/dynamic-labs/react-native-expo`;
if (directoryExists) {
await askForNewDirectory(directoryName, repoUrl);
} else {
await cloneRepository(repoUrl, directoryName);
}
return `https://github.com/dynamic-labs/${answers.framework}-${answers.library}${answers.wagmi ? '-' + answers.wagmi : ''}`;
}
main();
export async function main() {
const initialAnswers = await askFrameworkQuestion();
const answers = await askAdditionalQuestions(initialAnswers);
const repoUrl = generateRepoUrl(answers);
const directoryName = process.argv[2] || 'my-dynamic-project';
const directoryExists = await checkDirectoryExists(directoryName);
if (directoryExists) {
await askForNewDirectory(directoryName, repoUrl);
} else {
await cloneRepository(repoUrl, directoryName);
}
const url = "https://app.dynamic.xyz/dashboard/developer/api";
console.log(chalk.magenta('Make sure to grab your Environment ID from ') + url + chalk.magenta(' and add it to the DynamicContextProvider!'))
}
if (!process.env.TEST_ENV) {
main();
}
{
"name": "create-dynamic-app",
"version": "0.1.1",
"version": "0.1.6",
"description": "",

@@ -8,3 +8,3 @@ "main": "index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "TEST_ENV=true mocha 'index.test.js'"
},

@@ -22,3 +22,13 @@ "bin": {

"simple-git": "^3.24.0"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.5",
"@babel/runtime": "^7.24.5",
"chai": "^4.1.1",
"cross-env": "^7.0.3",
"esm": "^3.2.25",
"mocha": "^10.4.0",
"ts-node": "^10.9.2"
}
}
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