createProjectStructure() {
    const curDir = path.resolve(this._path);

    try {
      if (!fs.existsSync(curDir)) {
        return "The widget folder already exists in you HDD";
      } else {
        // create the container folder
        fs.mkdirSync(`${curDir}/${this._extensionName}`);

        //create the widget folder
        fs.mkdirSync(`${curDir}/${this._extensionName}/widget`);

        // create the widget name folder
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${this._extensionName}`
        );

        //create the js folder
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${this._extensionName}/js`
        );

        //create the less folder
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${this._extensionName}/less`
        );

        //create the template folder
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/templates`
        );

        //create the config folder
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/config`
        );

        // create the ext.json file
        fs.writeFile(
          `${curDir}/${this._extensionName}/ext.json`,
          this.createExtJson(),
          error => {
            if (error) {
              throw new Error("Cannot write file ext.json");
            }
          }
        );

        //create the widget.json file
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/widget.json`,
          this.createWidgetJson(),
          error => {
            if (error) {
              throw new Error("Cannot write file widget.json");
            }
          }
        );

        //create the javascript file
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/js/widget-javascript.js`,
          this.createJavascriptFile(),
          error => {
            if (error) {
              throw new Error("Cannot write file widget-javascript.js");
            }
          }
        );

        //create the display.template file
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/templates/display.template`,
          this.createTheHtmlTemplate(),
          error => {
            if (error) {
              throw new Error("Cannot write display.template file");
            }
          }
        );

        //create the widget.less file
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/less/widget.less`,
          this.createTheLessFile(),
          error => {
            if (error) {
              throw new Error("Cannot write widget.less file");
            }
          }
        );

        var result = {
          status: 200,
          directory: curDir,
          extension: this._extensionName
        };

        return result;
      }
    } catch (error) {
      return "There was an error generating the file";
    }
  }
/**
   * Create the base folder structure for the widget
   */
Create the base folder structure for the widget
Create the base folder structure for the widget
createProjectStructure() {
    const curDir = path.resolve(this._path);
    try {
      if (!fs.existsSync(curDir)) {
        return "The widget folder already exists in you HDD";
      } else {
        fs.mkdirSync(`${curDir}/${this._extensionName}`);
        fs.mkdirSync(`${curDir}/${this._extensionName}/widget`);
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${this._extensionName}`
        );
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${this._extensionName}/js`
        );
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${this._extensionName}/less`
        );
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/templates`
        );
        fs.mkdirSync(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/config`
        );
        fs.writeFile(
          `${curDir}/${this._extensionName}/ext.json`,
          this.createExtJson(),
          error => {
            if (error) {
              throw new Error("Cannot write file ext.json");
            }
          }
        );
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/widget.json`,
          this.createWidgetJson(),
          error => {
            if (error) {
              throw new Error("Cannot write file widget.json");
            }
          }
        );
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/js/widget-javascript.js`,
          this.createJavascriptFile(),
          error => {
            if (error) {
              throw new Error("Cannot write file widget-javascript.js");
            }
          }
        );
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/templates/display.template`,
          this.createTheHtmlTemplate(),
          error => {
            if (error) {
              throw new Error("Cannot write display.template file");
            }
          }
        );
        fs.writeFile(
          `${curDir}/${this._extensionName}/widget/${
            this._extensionName
          }/less/widget.less`,
          this.createTheLessFile(),
          error => {
            if (error) {
              throw new Error("Cannot write widget.less file");
            }
          }
        );
        var result = {
          status: 200,
          directory: curDir,
          extension: this._extensionName
        };
        return result;
      }
    } catch (error) {
      return "There was an error generating the file";
    }
  }
createProjectStructure ( ) { const curDir = path . resolve ( this . _path ) ; try { if ( ! fs . existsSync ( curDir ) ) { return "The widget folder already exists in you HDD" ; } else { fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ` ) ; fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ` ) ; fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` ) ; fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` ) ; fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` ) ; fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` ) ; fs . mkdirSync ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` ) ; fs . writeFile ( ` ${ curDir } ${ this . _extensionName } ` , this . createExtJson ( ) , error => { if ( error ) { throw new Error ( "Cannot write file ext.json" ) ; } } ) ; fs . writeFile ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` , this . createWidgetJson ( ) , error => { if ( error ) { throw new Error ( "Cannot write file widget.json" ) ; } } ) ; fs . writeFile ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` , this . createJavascriptFile ( ) , error => { if ( error ) { throw new Error ( "Cannot write file widget-javascript.js" ) ; } } ) ; fs . writeFile ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` , this . createTheHtmlTemplate ( ) , error => { if ( error ) { throw new Error ( "Cannot write display.template file" ) ; } } ) ; fs . writeFile ( ` ${ curDir } ${ this . _extensionName } ${ this . _extensionName } ` , this . createTheLessFile ( ) , error => { if ( error ) { throw new Error ( "Cannot write widget.less file" ) ; } } ) ; var result = { status : 200 , directory : curDir , extension : this . _extensionName } ; return result ; } } catch ( error ) { return "There was an error generating the file" ; } }
Create the base folder structure for the widget
Create the base folder structure for the widget
// create the container folder //create the widget folder // create the widget name folder //create the js folder //create the less folder //create the template folder //create the config folder // create the ext.json file //create the widget.json file //create the javascript file //create the display.template file //create the widget.less file