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
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"tools-build": "npm run rush-tools -- run gulp-build -e @simplr/mvdir",
"source-build": "npm run rush-tools -- run build -e @simplr/mvdir",
"test": "npm run rush-tools -- run test -e @simplr/mvdir",
"rush-tools": "ts-node ./tools/rush-tools.ts",
"publish": "npm run rush-tools -- publish --access public"
"publish": "npm run rush-tools -- publish --access public",
"rush-tools": "ts-node ./tools/rush-tools.ts"
},
"devDependencies": {
"@microsoft/rush": "^3.0.11",
Expand All @@ -19,5 +19,10 @@
"ts-node": "^3.1.0",
"typescript": "^2.4.1",
"yargs": "^8.0.2"
},
"dependencies": {
"@microsoft/ts-command-line": "^2.0.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in devDependencies

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: 479b296

"@types/semver": "^5.3.32",
"semver": "^5.3.0"
}
}
12 changes: 11 additions & 1 deletion packages/react-forms-dom/src/components/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import {
BaseFormButtonProps,
BaseFormButtonStateRecord
} from "../abstractions/base-form-button";
import { HTMLElementProps } from "../contracts/field";

export type SubmitProps = BaseFormButtonProps;
export interface SubmitProps extends BaseFormButtonProps, HTMLElementProps<HTMLButtonElement> {
fieldIds?: string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Author

@MartynasZilinskas MartynasZilinskas Jul 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed: 9b52929


ref?: React.Ref<Submit>;
}

export class Submit extends BaseFormButton<SubmitProps, BaseFormButtonStateRecord> {
public static defaultProps: BaseFormButtonProps = {
Expand All @@ -23,6 +28,11 @@ export class Submit extends BaseFormButton<SubmitProps, BaseFormButtonStateRecor
if (this.props.formId !== null) {
this.FormStore.InitiateFormSubmit();
}

if (this.props.onClick != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, rename the function OnButtonClick to onClick. It's a bit more unified.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in case it's protected, it should be named OnClick 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: 9b52929

event.persist();
this.props.onClick(event);
}
}

public render(): JSX.Element {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-forms-dom/src/contracts/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
} from "../contracts/field";

export interface FormOnSubmitInternalCallback {
(event: React.FormEvent<HTMLFormElement>, ...parameters: any[]): void | Promise<never> | FormError | string;
(event: React.FormEvent<HTMLFormElement>, ...parameters: any[]): void | Promise<void> | FormError | string;
}

export interface FormOnSubmitCallback {
(event: React.FormEvent<HTMLFormElement>, store: FormStore): void | Promise<never> | FormError | string;
(event: React.FormEvent<HTMLFormElement>, store: FormStore): void | Promise<void> | FormError | string;
}

export interface FormProps extends CoreFormProps, React.HTMLProps<HTMLFormElement> {
Expand Down
276 changes: 276 additions & 0 deletions tools/rush-tools-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
import * as path from "path";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the file name called rush-tools-new?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed old rush-tools file and renamed rush-tools-new to rush-tools.
Fixed: 479b296

import * as shelljs from "shelljs";
import * as semver from "semver";

import {
CommandLineParser,
CommandLineFlagParameter,
CommandLineAction,
CommandLineStringListParameter,
CommandLineStringParameter
} from "@microsoft/ts-command-line";

import { RushConfiguration } from "@microsoft/rush-lib";

// Tasks

class ShellTask {
constructor(private rushConfiguration: RushConfiguration, private projects: string[]) { }

public Execute(command: string): void {
this.consoleWrite(`Starting: ${command}`);

const failedProjects: string[] = [];
const succeededProjects: string[] = [];

for (const projectName of this.projects) {
const project = this.rushConfiguration.getProjectByName(projectName);

shelljs.cd(project.projectFolder);
this.consoleBox(`Package name: ${projectName}`);

const result = shelljs.exec(command);

if (result.code === 0) {
succeededProjects.push(projectName);
} else {
failedProjects.push(projectName);
}
}

if (succeededProjects.length > 0) {
this.consoleBox(`Succeeded projects ${succeededProjects.length}`);
for (const project of succeededProjects) {
this.consoleWrite(project);
}
}

if (failedProjects.length > 0) {
this.consoleBox(`Failed projects ${failedProjects.length}`);
for (const project of failedProjects) {
this.consoleWrite(project);
}
process.exit(1);
}
}

private consoleWrite(...text: string[]): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What?.. Why do you need this function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first it was writing to console with a prefix, later on I removed it.
Fixed: 479b296

console.info(text.join(" "));
}

private consoleBox(message: string): void {
this.consoleWrite("====================================");
this.consoleWrite(message);
this.consoleWrite("====================================");
}
}

// Actions

const defaultRushJsonFile = "rush.json";

abstract class BaseAction extends CommandLineAction {
protected RushConfiguration: RushConfiguration;

protected onExecute(): void {
if (this.RushConfiguration == null) {
this.RushConfiguration = RushConfiguration.loadFromDefaultLocation();
}
this.run();
}

protected abstract run(): void;
}

class RushRunAction extends BaseAction {
private parser: RushToolsCommandLineParser;

private excluded: CommandLineStringListParameter;
private script: CommandLineStringParameter;

constructor(parser: RushToolsCommandLineParser) {
super({
actionVerb: "run",
summary: "Runs scripts to all projects",
documentation: "Runs scripts to all projects"
});
this.parser = parser;
}

protected onDefineParameters(): void {
this.excluded = this.defineStringListParameter({
parameterShortName: "-e",
parameterLongName: "--exclude",
description: "List of excluded project names"
});

this.script = this.defineStringParameter({
parameterShortName: "-s",
parameterLongName: "--script",
description: "Name of script that will be run in projects"
});
}

protected run(): void {
if (this.script.value == null) {
console.error("[RUN] Please specify script name with --script/-s parameter.");
process.exit(1);
}

const excludedProjects = this.excluded.value;
const projects = this.RushConfiguration
.projects
.map(x => x.packageName)
.filter(x => excludedProjects.indexOf(x) === -1);

const task = new ShellTask(this.RushConfiguration, projects);
task.Execute(`npm run ${this.script.value}`);
}
}

class RushPublicAction extends BaseAction {
private parser: RushToolsCommandLineParser;

private excluded: CommandLineStringListParameter;
private access: CommandLineStringParameter;

constructor(parser: RushToolsCommandLineParser) {
super({
actionVerb: "publish",
summary: "Runs publish script on all projects",
documentation: "Runs publish script on all projects"
});
this.parser = parser;
}

protected onDefineParameters(): void {
this.excluded = this.defineStringListParameter({
parameterShortName: "-e",
parameterLongName: "--exclude",
description: "List of excluded project names"
});

this.access = this.defineStringParameter({
parameterLongName: "--access",
description: "Publish package to public/private"
});
}

protected run(): void {
const excludedProjects = this.excluded.value || [];
const projects = this.RushConfiguration
.projects
.filter(x => x.shouldPublish)
.map(x => x.packageName)
.filter(x => excludedProjects.indexOf(x) === -1);

const task = new ShellTask(this.RushConfiguration, projects);
const access = this.access.value != null ? `--access ${this.access.value}` : "";
task.Execute(`npm publish ${access}`);
}
}

class RushVersionsAction extends BaseAction {
private parser: RushToolsCommandLineParser;
private publishOnly: CommandLineFlagParameter;

constructor(parser: RushToolsCommandLineParser) {
super({
actionVerb: "versions",
summary: "Prints list of projects versions",
documentation: "Prints list of projects versions"
});
this.parser = parser;
}

protected onDefineParameters(): void {
this.publishOnly = this.defineFlagParameter({
parameterLongName: "--publishOnly",
description: "List only for publish"
});
}

protected run(): void {
const { projects } = this.RushConfiguration;
const publishOnly = this.publishOnly.value;

console.info(`Projects: ${projects.length}`);
console.info("======================================");
for (const project of projects) {
if (publishOnly && !project.shouldPublish) {
continue;
}
console.info(`${project.packageName}@${project.packageJson.version}`);
}
}
}

class RushBumpAction extends BaseAction {
private parser: RushToolsCommandLineParser;

private excluded: CommandLineStringListParameter;
private increment: CommandLineStringParameter;

constructor(parser: RushToolsCommandLineParser) {
super({
actionVerb: "bump",
summary: "Bumps versions to all projects that have shouldPublish",
documentation: "Bumps versions to all projects that have shouldPublish"
});
this.parser = parser;
}

protected onDefineParameters(): void {
this.excluded = this.defineStringListParameter({
parameterShortName: "-e",
parameterLongName: "--exclude",
description: "List of excluded project names"
});

this.increment = this.defineStringParameter({
parameterShortName: "-i",
parameterLongName: "--inc",
description: "Release type: major, premajor, minor, preminor, patch, prepatch, or prerelease."
});
}

protected run(): void {
if (this.increment.value == null) {
console.error("[BUMP] Please specify bump type: major, premajor, minor, preminor, patch, prepatch, or prerelease.");
process.exit(1);
}



const excludedProjects = this.excluded.value || [];
}


}

// CLI

class RushToolsCommandLineParser extends CommandLineParser {
constructor() {
super({
toolFilename: "rush-tools",
toolDescription: "Rush tools for rush single repo tool"
});

this.populateActions();
}

protected onDefineParameters(): void {
// Abstract
}

private populateActions(): void {
this.addAction(new RushRunAction(this));
this.addAction(new RushPublicAction(this));
this.addAction(new RushVersionsAction(this));
}
}

const cli = new RushToolsCommandLineParser();
cli.execute();