Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from CaribouJohn/webpack
Browse files Browse the repository at this point in the history
Webpack missed changes
  • Loading branch information
CaribouJohn authored May 13, 2021
2 parents 3427810 + 4389a49 commit fa75f2c
Show file tree
Hide file tree
Showing 4 changed files with 7,606 additions and 304 deletions.
28 changes: 14 additions & 14 deletions commands/create-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ var rif = require('replace-in-file');
const { spawn } = require('child_process');

async function createWidget(args) {
console.log(args);
//console.log(args);
// Create the workspace if it doesn't already exist.
if (fs.existsSync('angular.json')) {
console.log("You are in an Angular project this command should be run in an empty directory.");
return;
}

if (fs.existsSync(`${args.project}`)) {
console.log(`Cannot create project, ${args.project} already exists`);
if (fs.existsSync(`${args.name}`)) {
console.log(`Cannot create project, ${args.name} already exists`);
return;
}

Expand All @@ -24,16 +24,16 @@ async function createWidget(args) {

//ng new Project-Name
//cd Project - Name;
let command = `c8ycli new ${args.project} cockpit -a @c8y/${cumulocity_version} `;
console.log(`Creating ${args.project} - ${command}`);
let command = `npx @c8y/cli new ${args.name} cockpit -a @c8y/${cumulocity_version} `;
console.log(`Creating ${args.name} - ${command}`);
let child = spawn(command, { encoding: 'utf8', shell: true });
for await (const data of child.stdout) {
console.log(`${data}`);
};


console.log("Changing to project directory");
process.chdir(args.project);
process.chdir(args.name);

// EXPECT widget name in kebab/dotted/or "separated in some way"
// form a.b.c <=> d_e-f <=> g h i , single identifiers will work if required
Expand Down Expand Up @@ -70,9 +70,9 @@ async function createWidget(args) {


//debug
console.log("__CLASSNAME__ => " + className);
console.log("__DASHEDNAME__ => " + dashedName); // filenames and css classnames
console.log("__DOTTEDNAME__ => " + dottedName); // namespaces and config ids
//console.log("__CLASSNAME__ => " + className);
//console.log("__DASHEDNAME__ => " + dashedName); // filenames and css classnames
//console.log("__DOTTEDNAME__ => " + dottedName); // namespaces and config ids

console.log("modifying package.json");
const packageJSON = JSON.parse(fs.readFileSync("package.json"));
Expand Down Expand Up @@ -107,7 +107,7 @@ async function createWidget(args) {

// console.log("Adding proxy to angular.json");
// const angularJSON = JSON.parse(fs.readFileSync("angular.json"));
// angularJSON.projects[`${args.project}`].architect.serve["proxyConfig"] = "src/proxy.conf.json";
// angularJSON.projects[`${args.name}`].architect.serve["proxyConfig"] = "src/proxy.conf.json";
// fs.writeFileSync("angular.json", JSON.stringify(angularJSON, null, 4));


Expand Down Expand Up @@ -197,23 +197,23 @@ async function createWidget(args) {
rifOpts.from = /\_\_DASHEDNAME\_\_/g;
rifOpts.to = dashedName;
await rif(rifOpts);
console.log(`npm install base (local) ${args.project}`);
console.log(`npm install base (local) ${args.name}`);
command = `npm install`;
child = spawn(command, { encoding: 'utf8', shell: true });
for await (const data of child.stdout) {
console.log(`${data}`);
};


console.log(`npm install base (local/runtime) ${args.project}/runtime`);
console.log(`npm install base (local/runtime) ${args.name}/runtime`);
process.chdir('runtime');
command = `npm install`;
child = spawn(command, { encoding: 'utf8', shell: true });
for await (const data of child.stdout) {
console.log(`${data}`);
};
//need for theruntime widget build not for the general dev
console.log(`npm adding dev dependencies (local/runtime) for ${args.project}`);
//need for the runtime widget build not for the general dev
console.log(`npm adding dev dependencies (local/runtime) for ${args.name}`);
command = `npm install --save-dev @c8y/ngx-components@${cumulocity_version}`;
child = spawn(command, { encoding: 'utf8', shell: true });
for await (const data of child.stdout) {
Expand Down
38 changes: 18 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ yargs
demand: true,
choices: TEMPLATES,
},
project: {
demand: true,
},
name: {
demand: true,
},
Expand All @@ -43,21 +40,22 @@ yargs
},
})
//add elements to the widget
.command({
command: 'add [type] [names...]',
aliases: ['g'],
describe: 'Add dependencies or class ',
handler: addCommand,
builder: {
type: {
demand: true,
choices: ['dependency', 'class'],
default: 'dependency',
},
names: {
demand: true,
array: true,
},
},
}).parse(process.argv.slice(2)); //ignore the first two args
// .command({
// command: 'add [type] [names...]',
// aliases: ['g'],
// describe: 'Add dependencies or class ',
// handler: addCommand,
// builder: {
// type: {
// demand: true,
// choices: ['dependency', 'class'],
// default: 'dependency',
// },
// names: {
// demand: true,
// array: true,
// },
// },
// })
.parse(process.argv.slice(2)); //ignore the first two args

Loading

0 comments on commit fa75f2c

Please sign in to comment.