{"id":22389752,"url":"https://github.com/entando/fpg","last_synced_at":"2025-03-26T21:27:06.327Z","repository":{"id":47951429,"uuid":"215320935","full_name":"entando/fpg","owner":"entando","description":"Frontend Project Generator","archived":false,"fork":false,"pushed_at":"2021-08-11T14:08:19.000Z","size":97,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-01T03:27:43.459Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/entando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-15T14:33:54.000Z","updated_at":"2025-01-09T16:19:31.000Z","dependencies_parsed_at":"2022-08-12T15:00:44.899Z","dependency_job_id":null,"html_url":"https://github.com/entando/fpg","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Ffpg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Ffpg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Ffpg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Ffpg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/entando","download_url":"https://codeload.github.com/entando/fpg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245737924,"owners_count":20664182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T03:13:10.811Z","updated_at":"2025-03-26T21:27:06.306Z","avatar_url":"https://github.com/entando.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frontend Project Generator\n\nthis `npx` script generates frontend projects for entando.\n\nthe given commands are available:\n\n- `npx @entando/fpg ab-app \u003cappName\u003e`: generates an app-builder app.\n- `npx @entando/fpg react-widget \u003cname\u003e`: generates a react widget.\n\n## Extending fpg\n\nfpg can be used to generate any frontend project and can easily be extended to add different blueprints.\n\n### add the new boilerplate in the `boilerplates` directory.\n\na new directory has to be created and it should contain all the files that are going to be copied when generating the empty project.\n\n### add the new command in commander using as an example the `ab-app` command\n\n```js\nprogram\n  .command('ab-app')\n  .description('generates an app-builder app')\n  .arguments('\u003capp\u003e')\n  .action((app) =\u003e {\n    Log.title('app-builder app generator').section('create app structure');\n    const appDirName = nameResolver.getDirName(app);\n    const appName = nameResolver.getAppName(app);\n    const boilerplateDir = `${__dirname}/boilerplates/app-builder-app`;\n\n    createDirectory(appDirName, appName);\n    createPackage(app, appDirName, boilerplateDir);\n\n    bpGenerator.createBoilerplate(appDirName, boilerplateDir);\n    replacePlaceholders(appDirName, appName, boilerplateDir);\n\n    Log.section('install dependencies');\n    execSync('npm install', { stdio: [0, 1, 2], cwd: appDirName });\n    Log.section('install peer dependencies');\n    execSync('npx npm-install-peers', { stdio: [0, 1, 2], cwd: appDirName });\n    Log.empty().success('you can now run the app with `npm start`');\n  });\n```\n\nseveral utilities are used within the command:\n\n#### `nameResolver.getDirName(name)`\n\nreturns a kebab case version of the given name, removing any `@` prefix.\n\ni.e.\n\n@entando/whatever -\u003e entando-whatever\n\n#### `nameResolver.getAppName(name)`\n\nreturns the app name without the vendor scope.\n\ni.e.\n\n@entando/whatever -\u003e whatever\n\n#### `createDirectory(dirName, appName)`\n\ncreates in the cwd a directory with the given `dirName`.\n`appName` is just used to display information with Log.\n\n#### `createPackage(app, dirName, boilerplateDir)`\n\ncreates the package.json file replacing the `name` property with the value of `app`.\nthis function copies the file `package` inside the boilerplate directory and renames it `package.json`\n\n`dirName` is the path of the directory created by `createDirectory()`.\n`boilerplateDir` is the path of the boilerplate directory of the generated project.\n\n#### `bpGenerator.createBoilerplate(dirName, boilerplateDir, additionalPaths = [])`\n\ncopies over the boilerplate files from the boilerplate directory to the project directory.\n`dirName` is the path of the directory created by `createDirectory()`.\n`boilerplateDir` is the path of the boilerplate directory of the generated project.\n`paths` is an array of paths of files / directories that need to be copied over. Each path should be relative to `boilerplateDir`. If the files need to be renamed an object can be passed instead:\n\n```js\n[\n  { 'gitignore': '.gitignore' },\n  'jsconfig.json',\n  'README.md',\n  'src',\n  'public',\n]\n```\n\nthe given files and directories are being copied over:\n\n- README.md\n- gitignore renamed in .gitignore\n- .env\n- .sass-lint.yml\n- jsconfig.json\n- public/\n- src/\n\n#### `bpGenerator.createCustomBoilerplate(dirName, boilerplateDir, paths)`\ncopies over the boilerplate files from the boilerplate directory to the project directory.\n`dirName` is the path of the directory created by `createDirectory()`.\n`boilerplateDir` is the path of the boilerplate directory of the generated project.\n`additionalPaths` is an array of paths of additional files / directories that need to be copied over. Each path should be relative to `boilerplateDir`. If the files need to be renamed an object can be passed instead:\n\n```js\n[\n  { 'gitignore': '.gitignore' },\n  'jsconfig.json',\n  'README.md',\n  'src',\n  'public',\n]\n```\n\n#### `replacePlaceholders(dirName, appName, boilerplateDir)`\n\ngets the list of files that needs replacement from the `replace-mapping.js` module that is in the root of the given boilerplate.\n\nEach file is opened and every instance of `APP_NAME` is replaced by the lowercase version of `appName` while every instance of `UCASE_APP_NAME` is replaced by the uppercase version of `appName`.\n\n`dirName` is the path of the directory created by `createDirectory()`.\n`appName` is the name of the app.\n`boilerplateDir` is the path of the boilerplate directory of the generated project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentando%2Ffpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fentando%2Ffpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentando%2Ffpg/lists"}