New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

create-devcycle-app

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-devcycle-app - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

bin/utils/logging/logSuccess.d.ts

11

bin/command.js

@@ -14,3 +14,4 @@ "use strict";

.option('-t, --template <string>', 'Template identifier')
.option('-k, --key <string>', 'DevCycle SDK Key');
.option('-k, --key <string>', 'DevCycle SDK Key')
.option('-s, --start', 'Start the development server once setup is complete');
commander_1.program.parse();

@@ -27,4 +28,10 @@ const options = commander_1.program.opts();

await (0, utils_1.installDependencies)(outputPath);
await (0, utils_1.logDevInstructions)(outputPath);
(0, utils_1.logSuccess)(outputPath);
if (options.start) {
await (0, utils_1.startDevServer)(outputPath);
}
else {
await (0, utils_1.logDevInstructions)(outputPath);
}
}
exports.default = run;

@@ -5,1 +5,3 @@ export * from './fetchSourceCode';

export * from './logging';
export * from './startDevServer';
export * from './parseDevInstructions';

@@ -21,1 +21,3 @@ "use strict";

__exportStar(require("./logging"), exports);
__exportStar(require("./startDevServer"), exports);
__exportStar(require("./parseDevInstructions"), exports);
export * from './logDevInstructions';
export * from './logStatus';
export * from './logSuccess';
export * from './logWarning';

@@ -19,1 +19,3 @@ "use strict";

__exportStar(require("./logStatus"), exports);
__exportStar(require("./logSuccess"), exports);
__exportStar(require("./logWarning"), exports);

27

bin/utils/logging/logDevInstructions.js

@@ -8,31 +8,12 @@ "use strict";

const chalk_1 = __importDefault(require("chalk"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const __1 = require("..");
const logDevInstructions = async (outputPath) => {
const readmePath = path_1.default.resolve(outputPath, 'README.md');
if (!fs_1.default.existsSync(readmePath)) {
throw new Error('Unable to find README.md file');
}
let devInstructions = await getDevContent(readmePath);
let devInstructions = await (0, __1.parseDevInstructions)(outputPath);
devInstructions = changeDirectory(devInstructions, outputPath);
devInstructions = replaceLinks(devInstructions);
devInstructions = highlightCode(devInstructions);
console.log('-------------------------------');
console.log(`\n${chalk_1.default.greenBright('Success!')} Project created in ${path_1.default.resolve(outputPath)}`);
console.log('Get started by running the development server: \n\n' + devInstructions);
console.log('\n----------------------------------------');
console.log('How to run the development server: \n\n' + devInstructions);
};
exports.logDevInstructions = logDevInstructions;
const getDevContent = async (filePath) => {
return new Promise((resolve, reject) => {
fs_1.default.readFile(filePath, 'utf8', (err, fileContent) => {
if (err)
return reject(err);
const [_, match] = new RegExp(/### Development(?:[\s]*)([\s\S]*?)##/g).exec(fileContent) || [];
if (!match) {
return reject(new Error('Unable to parse development instructions'));
}
resolve(match);
});
});
};
const changeDirectory = (output, outputPath) => {

@@ -39,0 +20,0 @@ return `\`cd ${outputPath}\`\n${output}`;

{
"name": "create-devcycle-app",
"version": "1.0.5",
"version": "1.1.0",
"description": "A command line tool for generating DevCycle example apps",

@@ -5,0 +5,0 @@ "engines": {

@@ -25,2 +25,4 @@ import fs from 'fs'

let mockInstallDependencies: jest.SpyInstance
let mockLogSuccess: jest.SpyInstance
let mockStartDevServer: jest.SpyInstance
let mockLogDevInstructions: jest.SpyInstance

@@ -40,2 +42,4 @@

mockInstallDependencies = jest.spyOn(utils, 'installDependencies')
mockLogSuccess = jest.spyOn(utils, 'logSuccess')
mockStartDevServer = jest.spyOn(utils, 'startDevServer')
mockLogDevInstructions = jest.spyOn(utils, 'logDevInstructions')

@@ -111,7 +115,27 @@ })

it('should call logDevInstructions', async () => {
it('should call logSuccess', async () => {
await run()
expect(mockLogSuccess).toHaveBeenCalledWith('/path/to/output')
})
it('should call startDevServer when options.start is set', async () => {
mockOpts.mockReturnValue({
template: 'my-template',
key: 'my-sdk-key',
start: true,
})
await run()
expect(mockStartDevServer).toHaveBeenCalledWith('/path/to/output')
expect(mockLogDevInstructions).not.toHaveBeenCalled()
})
it('should call logDevInstructions when options.start is not set', async () => {
await run()
expect(mockLogDevInstructions).toHaveBeenCalledWith('/path/to/output')
expect(mockStartDevServer).not.toHaveBeenCalled()
})
})

@@ -8,3 +8,5 @@ import { program } from 'commander'

installDependencies,
logDevInstructions
logDevInstructions,
logSuccess,
startDevServer
} from './utils'

@@ -17,2 +19,3 @@

.option('-k, --key <string>', 'DevCycle SDK Key')
.option('-s, --start', 'Start the development server once setup is complete')

@@ -35,3 +38,8 @@ program.parse();

await logDevInstructions(outputPath)
logSuccess(outputPath)
if (options.start) {
await startDevServer(outputPath)
} else {
await logDevInstructions(outputPath)
}
}
export * from './fetchSourceCode'
export * from './generateEnvFile'
export * from './installDependencies'
export * from './logging'
export * from './logging'
export * from './startDevServer'
export * from './parseDevInstructions'
export * from './logDevInstructions'
export * from './logStatus'
export * from './logStatus'
export * from './logSuccess'
export * from './logWarning'

@@ -55,20 +55,2 @@ import fs from 'fs'

})
it('should error if README.md does not exist in output directory', async () => {
mockExistsSync.mockReturnValue(false)
await expect(logDevInstructions(outputPath)).rejects.toThrow(
new Error('Unable to find README.md file')
)
})
it('should error if unable to parse development instructions', async () => {
mockReadFile.mockImplementation((path, encoding, callback) => {
callback(null, '### invalid readme content')
})
await expect(logDevInstructions(outputPath)).rejects.toThrow(
new Error('Unable to parse development instructions')
)
})
})
import chalk from 'chalk'
import fs from 'fs'
import path from 'path'
import { parseDevInstructions } from '..'
export const logDevInstructions = async (outputPath: string) => {
const readmePath = path.resolve(outputPath, 'README.md')
if (!fs.existsSync(readmePath)) {
throw new Error('Unable to find README.md file')
}
let devInstructions = await getDevContent(readmePath)
let devInstructions = await parseDevInstructions(outputPath)
devInstructions = changeDirectory(devInstructions, outputPath)

@@ -17,22 +12,6 @@ devInstructions = replaceLinks(devInstructions)

console.log('-------------------------------')
console.log(`\n${chalk.greenBright('Success!')} Project created in ${path.resolve(outputPath)}`)
console.log('Get started by running the development server: \n\n' + devInstructions)
console.log('\n----------------------------------------')
console.log('How to run the development server: \n\n' + devInstructions)
}
const getDevContent = async (filePath: string) => {
return new Promise<string>((resolve, reject) => {
fs.readFile(filePath, 'utf8', (err, fileContent) => {
if (err) return reject(err)
const [_, match] = new RegExp(/### Development(?:[\s]*)([\s\S]*?)##/g).exec(fileContent) || []
if (!match) {
return reject(new Error('Unable to parse development instructions'))
}
resolve(match)
})
})
}
const changeDirectory = (output: string, outputPath: string) => {

@@ -39,0 +18,0 @@ return `\`cd ${outputPath}\`\n${output}`

Sorry, the diff of this file is not supported yet

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