Skip to content
Open
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
59 changes: 21 additions & 38 deletions generators/app/generate-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
id: 'tool-html',
aliases: ['html', 'typescript', 'ts'],
name: 'HTML with TypeScript',

/**
* @param {Generator} generator
* @param {ToolConfig} toolConfig
Expand All @@ -24,69 +24,52 @@ export default {
await prompts.askForGit(generator, toolConfig);
await prompts.askForPackageManager(generator, toolConfig);
},

/**
* @param {Generator} generator
* @param {ToolConfig} toolConfig
*/
writing: (generator, toolConfig) => {
// Copy package.json template
generator.fs.copyTpl(
generator.templatePath('html/package.json'),
generator.destinationPath('package.json'),
toolConfig
);
generator.fs.copyTpl(generator.templatePath('html/package.json'), generator.destinationPath('package.json'), toolConfig);

// Copy tsconfig.json
generator.fs.copy(
generator.templatePath('html/tsconfig.json'),
generator.destinationPath('tsconfig.json')
);
generator.fs.copy(generator.templatePath('html/tsconfig.json'), generator.destinationPath('tsconfig.json'));

// Copy tsconfig.node.json
generator.fs.copy(generator.templatePath('html/tsconfig.node.json'), generator.destinationPath('tsconfig.node.json'));

// Copy tsconfig.node.json
generator.fs.copy(generator.templatePath('html/tsconfig.node.json'), generator.destinationPath('tsconfig.node.json'));

// Copy vite.config.ts
generator.fs.copy(generator.templatePath('html/vite.config.ts'), generator.destinationPath('vite.config.ts'));

// Copy .gitignore if git is initialized
if (toolConfig.gitInit) {
generator.fs.copy(
generator.templatePath('html/gitignore'),
generator.destinationPath('.gitignore')
);
generator.fs.copy(generator.templatePath('html/gitignore'), generator.destinationPath('.gitignore'));
}

// Copy .npmignore
generator.fs.copy(
generator.templatePath('html/npmignore'),
generator.destinationPath('.npmignore')
);
generator.fs.copy(generator.templatePath('html/npmignore'), generator.destinationPath('.npmignore'));

// Copy README
generator.fs.copyTpl(
generator.templatePath('html/README.md'),
generator.destinationPath('README.md'),
toolConfig
);
generator.fs.copyTpl(generator.templatePath('html/README.md'), generator.destinationPath('README.md'), toolConfig);

// Copy source files
generator.fs.copy(
generator.templatePath('html/src/index.html'),
generator.destinationPath('src/index.html')
);
generator.fs.copy(generator.templatePath('html/src/index.html'), generator.destinationPath('src/index.html'));

generator.fs.copy(
generator.templatePath('html/src/app.ts'),
generator.destinationPath('src/app.ts')
);
generator.fs.copy(generator.templatePath('html/src/app.ts'), generator.destinationPath('src/app.ts'));

generator.fs.copy(
generator.templatePath('html/src/styles.css'),
generator.destinationPath('src/styles.css')
);
generator.fs.copy(generator.templatePath('html/src/styles.css'), generator.destinationPath('src/styles.css'));
},

/**
* @param {Generator} generator
* @param {ToolConfig} toolConfig
*/
endMessage: (generator, toolConfig) => {
generator.log('Your HTML/TypeScript tool is ready!');
generator.log('Build your tool with: ' + (toolConfig.pkgManager === 'npm' ? 'npm run build' : toolConfig.pkgManager + ' build'));
}
},
};
49 changes: 36 additions & 13 deletions generators/app/templates/html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
│ ├── index.ts # Tool logic (TypeScript)
│ └── styles.css # Styling
├── dist/ # Compiled output (after build)
│ ├── index.html
│ ├── index.js
│ ├── index.js.map
│ └── styles.css
├── package.json
├── README.md
├── tsconfig.json
└── README.md
└── vite.config.ts
```

## Installation
Expand All @@ -38,18 +35,44 @@ npm install

## Development

Build the tool:
**Build the tool:**

```bash
npm run build
```

Watch mode for development:
**Dev build with sourcemaps (watch mode):**

```bash
npm run watch
npm run dev-watch
```

**Validate tool package:**

```bash
npm run validate
```

**Shrinkwrap package:**

```bash
npm run finalize-package
```

or;

```bash
npm shrinkwrap
```

**Publish new version:**

```bash
npm run publish-package
```

_Further tool development documentation is available @ https://docs.powerplatformtoolbox.com/tool-development_

## Usage in ToolBox

1. Build the tool using `npm run build`
Expand All @@ -72,18 +95,18 @@ console.log(context.accessToken);

```typescript
await window.toolboxAPI.showNotification({
title: 'Success',
body: 'Operation completed',
type: 'success'
title: 'Success',
body: 'Operation completed',
type: 'success',
});
```

### Subscribing to Events

```typescript
window.toolboxAPI.onToolboxEvent((event, payload) => {
console.log('Event:', payload.event);
console.log('Data:', payload.data);
console.log('Event:', payload.event);
console.log('Data:', payload.data);
});
```

Expand Down
56 changes: 30 additions & 26 deletions generators/app/templates/html/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
{
"name": "<%= name %>",
"version": "0.1.0",
"displayName": "<%= displayName %>",
"description": "<%= description %>",
"main": "index.html",
"author": "Power Platform ToolBox",
"license": "MIT",
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "tsc && npm run copy-html && npm run copy-css",
"copy-html": "shx cp src/index.html dist/",
"copy-css": "shx cp src/styles.css dist/",
"watch": "tsc --watch",
"finalize-package": "npm shrinkwrap"
},
"devDependencies": {
"@pptb/types": "^1.0.1",
"typescript": "^5.0.0",
"shx": "^0.4.0"
},
"files": [
"dist",
"npm-shrinkwrap.json"
]
"name": "<%= name %>",
"version": "0.1.0",
"displayName": "<%= displayName %>",
"description": "<%= description %>",
"main": "index.html",
"author": "Power Platform ToolBox",
"license": "MIT",
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"watch": "vite build --watch",
"dev-watch": "vite build --mode development --watch",
"preview": "vite preview",
"finalize-package": "npm shrinkwrap",
"validate": "pptb-validate",
"version-stable": "npm version patch --no-git-tag-version",
"publish-package": "npm run build && npm run version-stable && npm publish --access public"
},
"devDependencies": {
"@pptb/types": "^1.2.0",
"typescript": "^5.0.0",
"vite": "^8.0.3"
},
"files": [
"dist",
"npm-shrinkwrap.json"
]
}
Loading