Skip to content
Merged
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
2 changes: 1 addition & 1 deletion generics/add/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions generics/add/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "@scullyio/create-scully",
"version": "0.0.0",
"version": "0.0.10",
"description": "functions for add and use Scully in vue or react project",
"main": "index.js",
"bin": "index.js",
"scripts": {
"build": "tsc -p ./tsconfig.json",
"test": "echo \"Error: no test specified\" && exit 1",
"publish:patch": "tsc -p ./tsconfig.json && npm version patch && npm publish --access public",
"publish:minor": "tsc -p ./tsconfig.json && npm version minor && npm publish --access public",
"publish:major": "tsc -p ./tsconfig.json && npm version major && npm publish --access public"
"publish:major": "tsc -p ./tsconfig.json && npm version major && npm publish --access public",
"publish:patch:dist": "tsc -p ./tsconfig.json && npm version patch && cp ./package.json ../../dist/add && cd ../../dist/add && npm publish --access=public"
},
"author": "@scullyio",
"contributors": [
Expand Down
12 changes: 10 additions & 2 deletions generics/add/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/usr/bin/env node

import {scullyInstall} from './install';
import {addScullyScripts} from './npm';
import {createConfigFile} from './utils/utils';
import {createConfig} from './utils/utils';

scullyInstall();
addScullyScripts();
createConfigFile();
createConfig();

// tslint:disable-next-line:no-console
console.info(`
Now you can use Scully in your project.
For mor information please visit https://scully.io.
`);
2 changes: 2 additions & 0 deletions generics/add/src/install/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const exec = require('child_process').exec;
export const scullyInstall = () => {
// tslint:disable-next-line:no-console
console.info('Installing Scully');
exec('npm install @scullyio/scully', (error, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
Expand Down
2 changes: 2 additions & 0 deletions generics/add/src/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import {getPackageJson, overwritePackageJson} from '../utils/utils';

export const addScullyScripts = () => {
// tslint:disable-next-line:no-console
console.info("Adding Scully's scripts into package.json");
getPackageJson().then((jsonContent: any) => {
if (jsonContent === undefined) {
console.error('error not content into package.json');
Expand Down
17 changes: 10 additions & 7 deletions generics/add/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,31 @@ const checkLibAndName = () => {
resolve({lib: 'react', name});
} else if (content.indexOf('vue') > 0) {
resolve({lib: 'vue', name});
} else {
console.error('package.json not found react or vue library');
}
console.error('package.json not found react or vue library');
return;
});
});
};

const createConfigFile = () => {
const createConfig = () => {
// tslint:disable-next-line:no-console
console.info('Creating Scully config file.');
checkLibAndName().then((data: {lib: string; name: string}) => {
console.log(data);
const configName = `scully.${data.name}.config.js`;
const configFile = createConfig(data);
fs.writeFile(configName, JSON.stringify(configFile, null, 2), (err, content) => {
const configFile = createConfigFile(data);
fs.writeFile(configName, configFile, (err, content) => {
if (err) {
console.log(err);
return;
}
return;
});
});
};

const createConfig = data => {
const createConfigFile = data => {
return `exports.config = {
projectName: "${data.name}",
bareProject: true,
Expand All @@ -69,4 +72,4 @@ const createConfig = data => {
};`;
};

export {getPackageJson, overwritePackageJson, createConfigFile};
export {getPackageJson, overwritePackageJson, createConfig};