Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(igr-ts): add igr-ts proj type #1146

Merged
merged 70 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
338bd1e
switch to react functions initial commit
mtsvyatkova Aug 30, 2023
ab678d1
fix(igr-es6): switch to functions in all views
mtsvyatkova Sep 6, 2023
e859097
feat(igr-es6): add igr-ts-es6 proj type
onlyexeption Sep 13, 2023
504fd7b
fix(igr-ts-es6): update react router version and style import
onlyexeption Sep 14, 2023
865243c
Revert "fix(igr-es6): switch to functions in all views"
onlyexeption Sep 14, 2023
db1780c
Revert "switch to react functions initial commit"
onlyexeption Sep 14, 2023
cbfdf9a
chore(*): fix template names
onlyexeption Sep 14, 2023
237e8dd
chore(*): fix comment
onlyexeption Sep 14, 2023
53b9618
fix(igr-ts-es6): configure tests
mtsvyatkova Sep 14, 2023
5b662e2
chore(*): remove %PUBLIC_URL% from index.html
igdmdimitrov Sep 15, 2023
66dcf4b
chore(*): make app test more generic
mtsvyatkova Sep 18, 2023
ba26186
chore(*): update test config and clean leftovers
mtsvyatkova Sep 19, 2023
a0d59ca
chore(*): uncomment groups logic
onlyexeption Sep 19, 2023
ff4206f
chore(*): add config for igr-ts-es6 process
onlyexeption Sep 19, 2023
3c73ff9
chore(*): add groups.json
onlyexeption Sep 19, 2023
5cb30d2
feat(igr-ts-es6): add base with home template + minor chanegs
onlyexeption Sep 20, 2023
f22c14d
feat(igr-ts-es6): add view to top-nav
onlyexeption Sep 20, 2023
4fa476e
chore(*): update readme
onlyexeption Sep 25, 2023
0fb7a31
chore: release 12.0.6-alpha.0
Lipata Sep 25, 2023
7f6d432
feat(react): add base template
onlyexeption Sep 27, 2023
7d4121f
fix(react): igr-ts-es6 -> ig-ts
onlyexeption Sep 27, 2023
917a7dd
chore(*): minor change in React template
onlyexeption Sep 27, 2023
3fcdc88
chore: release 12.0.6-alpha.1
Lipata Sep 27, 2023
19aa3f2
chore: update react grid to latest #1147
onlyexeption Sep 28, 2023
58a6e48
chore: release 12.0.6-beta.0
onlyexeption Sep 28, 2023
6929287
chore: add force to install commands
onlyexeption Sep 29, 2023
8129ee7
feat(igr-ts): add deprecated to old react
igdmdimitrov Sep 29, 2023
2709698
Merge branch 'ibarakov/react-project-structure-vite' of https://githu…
igdmdimitrov Sep 29, 2023
33bc0be
chore: remove serviceWorker
onlyexeption Sep 29, 2023
9a1d6a7
chore: update packages
onlyexeption Sep 29, 2023
0c1564c
chore: formatting
onlyexeption Sep 29, 2023
38e154b
chore: remove asyncComponent
onlyexeption Sep 29, 2023
1948f8b
chore: fix lint
onlyexeption Sep 29, 2023
c027564
chore: add asyncComponent to top-nav
onlyexeption Sep 29, 2023
b708708
chore: remove unused imports
onlyexeption Oct 2, 2023
cc8c8d6
fix: search for empty template insted of first one
onlyexeption Oct 2, 2023
6992121
chore: fix lint
onlyexeption Oct 2, 2023
6c1b7c5
chore: unused import
onlyexeption Oct 2, 2023
5594c54
chore: unused imports
onlyexeption Oct 2, 2023
6c560cc
chore: release v12.0.6-beta.1
onlyexeption Oct 2, 2023
c8c550b
Merge branch 'master' into ibarakov/react-project-structure-vite
Lipata Oct 2, 2023
5b67e48
release: 12.1.0-beta.0
Lipata Oct 2, 2023
400122c
chore: set default port #1153
onlyexeption Oct 4, 2023
1da2943
chore: fix lint and remove .env file
onlyexeption Oct 4, 2023
14a2caa
chore: remove unused imports
onlyexeption Oct 4, 2023
524e174
feat: upgrade to react router 6
onlyexeption Oct 11, 2023
8ced6b0
chore: release 12.1.0-beta.1
onlyexeption Oct 11, 2023
5503b26
chore: fix lint
onlyexeption Oct 11, 2023
67f3fbe
chore: rename template files
onlyexeption Oct 24, 2023
7cd2895
chore: fix component registration
onlyexeption Oct 24, 2023
8cdf3b5
fix: igr-ts specificPath
onlyexeption Oct 24, 2023
6ed5f34
fix: react igr ts templates
onlyexeption Oct 25, 2023
1193ec1
chore: fix lint
onlyexeption Oct 25, 2023
26c215c
Merge branch 'master' into ibarakov/react-project-structure-vite
Lipata Oct 27, 2023
9ace912
chore: release 12.1.0-beta.2
Lipata Oct 27, 2023
09148d9
chore: remove obsolete files and packages
onlyexeption Oct 31, 2023
0d13896
chore: update igniteui-react version+remove unused func
onlyexeption Nov 6, 2023
425a6d7
chore: edit launch config
onlyexeption Nov 8, 2023
ebb998e
chore: release 12.1.0-beta.3
onlyexeption Nov 8, 2023
126c727
fix: use createBrowserRouter api
onlyexeption Nov 29, 2023
e3ecdc1
Merge branch 'master' into ibarakov/react-project-structure-vite
onlyexeption Nov 30, 2023
7ebd0e6
chore: release 12.1.0-beta.4
onlyexeption Nov 30, 2023
9335cb6
chore: fix package versions
onlyexeption Nov 30, 2023
dc0a194
chore: address PR comments
onlyexeption Dec 7, 2023
34bbe92
chore: remove empty line
onlyexeption Dec 7, 2023
55d0258
chore: add new line at the end
onlyexeption Dec 7, 2023
849d40c
chore: fix indentation
onlyexeption Dec 7, 2023
2889e22
chore: indent
onlyexeption Dec 7, 2023
1ef00de
fix: igr-es6 project
onlyexeption Dec 8, 2023
0cbfbf6
chore: fix lint
onlyexeption Dec 8, 2023
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
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@
"--framework=react"
]
},
{
"type": "node",
"request": "launch",
"name": "Launch New React TS ES6",
"cwd": "${workspaceRoot}/output",
"program": "${workspaceRoot}/packages/cli/bin/execute.js",
"console": "externalTerminal",
"preLaunchTask": "build",
"outFiles": ["${workspaceFolder}/**/*.js"],
"args": [
"new",
"reactproj",
"--framework=react",
"--type=igr-ts"
]
},
{
"type": "node",
"request": "launch",
Expand Down
19 changes: 14 additions & 5 deletions packages/cli/lib/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,20 @@ command = {
},
async addTemplate(fileName: string, template: Template, options?: AddTemplateArgs): Promise<boolean> {
if (!options) {
options = {
parentName: "app",
parentRoutingModulePath: "src/app/app-routing.ts",
selector: "app-" + template.id
};
if (template.framework === "react") {
options = {
parentName: "app",
parentRoutingModulePath: "src/app/app-routes.tsx",
className: Util.className(fileName),
modulePath: `src/app/${Util.lowerDashed(fileName)}`
};
} else {
options = {
parentName: "app",
parentRoutingModulePath: "src/app/app-routing.ts",
selector: "app-" + template.id
};
}
}

fileName = fileName.trim();
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/lib/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ command = {

const theme = projectLib.themes[themeIndex];

const projectTemplate = argv.template || projectLib.projectIds[0];
const indexOfEmptyOrFirst = projectLib.projectIds.indexOf("empty") !== -1 ?
onlyexeption marked this conversation as resolved.
Show resolved Hide resolved
projectLib.projectIds.indexOf("empty") :
0;

const projectTemplate = argv.template || projectLib.projectIds[indexOfEmptyOrFirst];
Util.log(`Project Name: ${argv.name}, framework ${argv.framework}, type ${projectLib.projectType}, theme ${theme}`);
const projTemplate = projectLib.getProject(projectTemplate);
if (projTemplate == null) {
Expand Down
16 changes: 10 additions & 6 deletions packages/cli/lib/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ command = {
break;
case "react":
if (port) {
// https://facebook.github.io/create-react-app/docs/advanced-configuration
// react-scripts start "--port=dafaultPort" is not a valid command for all environments.
// .env file is included and used by both igr-es6 and es6 now,
// to specify the port for all environments (Windows, Mac, etc)
process.env.PORT = `${port}`;
port = null;
if (projectType === "igr-ts") {
execSyncNpmStart(port, options);
} else {
// https://facebook.github.io/create-react-app/docs/advanced-configuration
// react-scripts start "--port=dafaultPort" is not a valid command for all environments.
// .env file is included and used by both igr-es6 and es6 now,
// to specify the port for all environments (Windows, Mac, etc)
process.env.PORT = `${port}`;
port = null;
}
}
/* falls through */
case "angular":
Expand Down
77 changes: 52 additions & 25 deletions packages/cli/lib/templates/IgniteUIForReactTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { AddTemplateArgs, ControlExtraConfiguration, defaultDelimiters, Template, Util } from "@igniteui/cli-core";
import * as fs from "fs-extra";
import {
AddTemplateArgs,
App,
ControlExtraConfiguration,
defaultDelimiters,
FS_TOKEN,
IFileSystem,
Template,
Util
} from "@igniteui/cli-core";
import * as path from "path";
import { ReactTypeScriptFileUpdate } from "../../templates/react/ReactTypeScriptFileUpdate";

export class IgniteUIForReactTemplate implements Template {
public components: string[];
Expand All @@ -12,15 +21,13 @@ export class IgniteUIForReactTemplate implements Template {
public description: string;
public dependencies: string[] = [];
public framework: string = "react";
public projectType = "igr-es6";
public projectType: string;
public hasExtraConfiguration: boolean = false;
public packages = [];
public delimiters = defaultDelimiters;
// non-standard template prop
protected widget: string;

private configFile: string = "./src/routes.json";

/**
* Base ReactTemplate constructor
* @param rootPath The template folder path. Pass in `__dirname`
Expand All @@ -40,6 +47,7 @@ export class IgniteUIForReactTemplate implements Template {
config["path"] = this.folderName(name); //folder name allowed spaces, any casing
config["name"] = Util.nameFromPath(name); // this name should not have restrictions
config["ClassName"] = Util.className(Util.nameFromPath(name)); //first letter capital, no spaces and no dashes,
config["filePrefix"] = Util.lowerDashed(Util.nameFromPath(name));
config["cliVersion"] = Util.version();
if (this.widget) {
config["widget"] = this.widget;
Expand All @@ -52,19 +60,48 @@ export class IgniteUIForReactTemplate implements Template {
return config;
}

public registerInProject(projectPath: string, name: string, options?: AddTemplateArgs) {
if (options && options.skipRoute) {
public registerInProject(projectPath: string, name: string, options?: AddTemplateArgs, defaultPath = false) {
if (!options.parentName) {
return;
}
const configFile = fs.readFileSync(path.join(projectPath, this.configFile), "utf8");
const viewsArr = JSON.parse(configFile);
viewsArr.push({
componentPath: this.getViewLink(name),
path: "/" + this.folderName(Util.nameFromPath(name)),
text: this.getToolbarLink(name)
});

fs.writeFileSync(path.join(projectPath, this.configFile), JSON.stringify(viewsArr, null, 4));
const routeModulePath: string = options.parentRoutingModulePath;
const routingModule = new ReactTypeScriptFileUpdate(path.join(projectPath, routeModulePath));

onlyexeption marked this conversation as resolved.
Show resolved Hide resolved
if (!(options && options.skipRoute) && App.container.get<IFileSystem>(FS_TOKEN)
.fileExists(routeModulePath)) {
onlyexeption marked this conversation as resolved.
Show resolved Hide resolved
let nameFromPath = Util.nameFromPath(name);
onlyexeption marked this conversation as resolved.
Show resolved Hide resolved
let lowerDashed = Util.lowerDashed(nameFromPath);
let filePath = path.posix.join(projectPath, options.modulePath, `${lowerDashed}.tsx`);

if (defaultPath) {
routingModule.addRoute("", options.className, nameFromPath, filePath, options.routerChildren, undefined);
}

routingModule.addRoute(
lowerDashed,
options.className,
nameFromPath,
filePath,
options.routerChildren,
undefined
);

if (options.hasChildren) {
nameFromPath = Util.nameFromPath(`${options.modulePath}-routes.tsx`);
lowerDashed = Util.lowerDashed(nameFromPath);
filePath = path.posix.join(projectPath, options.modulePath, nameFromPath);

routingModule.addRoute(
lowerDashed,
options.className,
nameFromPath,
filePath,
options.routerChildren,
options.importAlias
);
}
}
}
public getExtraConfiguration(): ControlExtraConfiguration[] {
throw new Error("Method not implemented.");
Expand Down Expand Up @@ -93,14 +130,4 @@ export class IgniteUIForReactTemplate implements Template {
}
return Util.lowerDashed(folderName);
}
protected getViewLink(name: string): string {
const filePath = "./views/" + this.folderName(name);
return filePath;
}

protected getToolbarLink(name: string): string {
name = Util.nameFromPath(name);
const toolbarLink = name.replace(/\w\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
return toolbarLink;
}
}
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "igniteui-cli",
"version": "13.0.2",
"version": "12.1.0-beta.4",
"description": "CLI tool for creating Ignite UI projects",
"keywords": [
"CLI",
Expand Down Expand Up @@ -78,8 +78,8 @@
"all": true
},
"dependencies": {
"@igniteui/angular-templates": "~17.0.1302",
"@igniteui/cli-core": "~13.0.2",
"@igniteui/angular-templates": "~17.0.1210-beta.4",
"@igniteui/cli-core": "~12.1.0-beta.4",
"chalk": "^2.3.2",
"fs-extra": "^3.0.1",
"glob": "^7.1.2",
Expand Down
Loading
Loading