Giter Club home page Giter Club logo

generator-office's Introduction

Yeoman generator for Office Add-ins - YO OFFICE!

npm version Downloads

This Yeoman generator creates a Node.js Office Add-in project that can be managed with Visual Studio Code or any other editor. You can use it to create Office Add-ins for:

  • Excel
  • OneNote
  • Outlook
  • PowerPoint
  • Project
  • Word

In addition you can use it to create add-ins that use single sign-on or Excel custom functions.

Like other Yeoman generators, this generator simply creates the scaffolding of files for your Office Add-in project. You can choose to create Office Add-in projects using plain HTML, CSS & JavaScript, or using React, and can choose between JavaScript and Typescript as well.

Note: While you can also use Visual Studio to create Office Add-in projects, the Yeoman generator provides more options in terms of the types of projects you can create. For example:

  • The Yeoman generator can create Office Add-in projects that use plain HTML, CSS & JavaScript, or React; whereas Visual Studio can only create Office Add-in projects that use plain HTML, CSS & JavaScript.
  • The Yeoman generator can create Office Add-ins projects that use either JavaScript or TypeScript; whereas Visual Studio only creates JavaScript projects which you would need to convert manually if you want to use TypeScript.
  • The Yeoman generator can create add-ins for Excel, OneNote, Outlook, PowerPoint, Project, and Word; whereas Visual Studio can only create add-ins for Excel, Outlook, PowerPoint, and Word.

For detailed information about installing and using the Yeoman generator to create Office Add-ins, see Create Office Add-in projects using the Yeoman Generator.

The generator is normally used in interactive mode, but you can use command line arguments and options as described in the sections below.

Usage

yo office [arguments] [options]

Command Line Arguments

The following command line arguments are supported. If using the command line arguments, you must use them in the order cited below, or the generator will prompt you for the values.

Example

yo office --projectType react --name "New Web AddIn" --host word --ts true
     _-----_     ╭──────────────────────────╮
    |       |    │   Welcome to the Office  │
    |--(o)--|    │   Add-in generator, by   │
   `---------´   │ @OfficeDev! Let's create │
    ( _´U`_ )    │    a project together!   │
    /___A___\   /╰──────────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

--projectType

Specifies the project type to create.

Project Type Description
taskpane Task Pane add-in using HTML
react Task Pane add-in using the React framework
excel-functions Task Pane add-in with Excel Custom Functions
single-sign-on Taskpane add-in supporting single-sign-on
manifest Manifest and related files for an Office Add-in
  • Type: String
  • Optional

--name

Title of the project - this is the display name that is written the manifest.xml file.

  • Type: String
  • Optional

Note: The Windows command prompt requires this argument to be in quotes (e.g. "My Office Add-in")

--host

The Microsoft Office client application that can host the add-in. The supported arguments include Excel (excel), OneNote (onenote), Outlook (outlook), PowerPoint (powerpoint), Project (project), and Word (word).

  • Type: String
  • Optional

Command Line Options

The following command line options are supported. If these are not specified, the generator will prompt you for the values before scaffolding the project. The options should be specified after the projectType, name and host arguments.

Specifying --output tells the generator to create the project in a specific location. If the output parameter is not specified, the project will be created in the current directory. If the output option specifies a non-empty folder, the generator will inform you so you don't accidentally overwrite existing files.

  • Type: String
  • Optional

Specifying --js tells the generator to use JavaScript.

  • Type: Boolean

  • Default: False

  • Optional

    Specifying --ts tells the generator to use TypeScript.

  • Type: Boolean

  • Default: False

  • Optional

    Specifying --details tells the generator to provide detailed help, including all the accepted values for each project type and host,

  • Type: Boolean

  • Default: False

  • Optional

--skip-install

After scaffolding the project, the generator (and all sub generators) run all package management install commands such as npm install & typings install. Specifying --skip-install tells the generator to skip this step.

  • Type: Boolean
  • Default: False
  • Optional

Running the Generated Site

Launch the local HTTPS site on https://localhost:3000 by simply typing the following command in your console:

npm start

Note: Office Add-ins should use HTTPS, not HTTP, even when you are developing. If you are prompted to install a certificate after you run npm start, accept the prompt to install the certificate that the Yeoman generator provides.

Next, sideload the add-in in an Office application. See Sideload an Office Add-in for testing.

Validate manifest.xml

As you modify your manifest.xml file, use the included Office Toolbox to ensure that your XML file is correct and complete. It will also give you information on against what platforms to test your add-ins before submitting to the store.

To run Office Add-in Validator, use the following command in your project directory:

npm run validate

For more information on manifest validation, refer to our add-in manifests documentation.

Contributing

If you are interested in contributing, please start by reading the Contributing Guidelines.

Development

Prerequisites

Ensure you have Node.js (version 8.0.0 or later) installed.

Install Yeoman.

npm install -g yo

Initialize the repo

git clone https://github.com/OfficeDev/generator-office.git
cd generator-office
npm install

Make your desired changes

Build and link your changes

npm run build
npm link
cd ..
yo office

At this point, yo office will be running with your custom built office-generator changes.

Data usage

Yo Office collects anonymized usage data and sends it to Microsoft. This allows us to understand how Yo Office is used and how to improve it.

For more details on what we collect and how to turn it off, see our Data usage notice


Copyright (c) 2017 Microsoft Corporation. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

generator-office's People

Contributors

akrantz avatar alexjerabek avatar andrewconnell avatar beth-panx avatar casieber avatar davidchesnut avatar dependabot[bot] avatar devarvindsa avatar igor-ribeiiro avatar jasonjoh avatar jozefizso avatar jthake avatar keyur32 avatar kwame-ansong avatar lindalu-msft avatar loumm avatar lucanerlich avatar martellaj avatar michaelmainer avatar millerds avatar nokafor avatar o365devx avatar pcostesi avatar rick-kirkham avatar roldengarm avatar stesee avatar tcourtneyowen avatar thorstenhans avatar waldekmastykarz avatar wrathofzombies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator-office's Issues

The generator overwrites existing tsd.json

When the generator is run on an existing project, the existing tsd.json file is overwritten. We should support updating existing tsd.json the same way we do it for the bower.json file.

Manifest file name based on project name

Rather than call every manifest "manifest.xml" actually create file name as "-manifest.xml". Makes it useful when having a shared network folder for a Trusted add-in catalog on a local machine when testing in Office Windows client.

Change names of the generated Gulp tasks to follow the naming convention

It seems like Gulp tasks follow the naming convention where a main task is a single word and a sub task consists of multiple words separated by a - or a :. In our case case the generated gulpfile.js files contain tasks such as serve-static and validate-xml. Shouldn't we have main tasks called serve and validate to call the existing sub tasks? We could either rename the existing tasks or add new tasks which would allow us for more flexibility in the future (like additional validation or serving files differently(?))?

Error: Unable to parse C:\Users\Jeremy\src\.bowerrc: Unexpected token M

Got this error on a fresh windows 10 environment with node, git installed after running

npm install -g yo generator-office bower

I used yo office and for folder location "\My First" and it threw an error. Iwanted it to create a sub folder and add there but it broke. Doing it with "/MyFirst" with no space and the bower bit works fine. Looks like its something on how the bower command is run.

It appears it doesn't adhere to the folder structure as not everything gets put in the subfolder "MyFirst".

Got this error

C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\util\rc.js:56
throw error;
^

Error: Unable to parse C:\Users\Jeremy\src.bowerrc: Unexpected token M
at parse (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\util\rc.js:49:21)
at C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\util\rc.js:76:20
at Array.forEach (native)
at json (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\util\rc.js:74:14)
at rc (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\util\rc.js:31:9)
at Config.load (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\Config.js:14:20)
at Function.Config.read (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\node_modules\bower-config\lib\Config.js:49:19)
at readCachedConfig (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\lib\config.js:21:51)
at defaultConfig (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\lib\config.js:11:24)
at Object. (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\bower\lib\index.js:40:32)

npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v4.1.2
npm ERR! npm v2.14.4
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: bower install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'bower install'.
npm ERR! This is most likely a problem with the my-first package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install
npm ERR! You can get their info via:
npm ERR! npm owner ls my-first
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Jeremy\src\npm-debug.log

C:\Users\Jeremy\src>

The gulp validate-xml task throws an exception

When running the $ gulp validate-xml task you get the TypeError: undefined is not a function error. This has to do with the fact that the xml is passed to the icon validation function as a string buffer rather than a string. Let me get that fixed.

Creation of TaskPane Addin failed.

Hi, i tried to create a TaskPane Addin and got the following error. Is is a bug or is there something I can do about?

This generator can also be run with: yo office
screen shot 2015-10-01 at 21 39 37

Add reference to /typings/tsd.d.ts in .js files

Generated projects have the tsd.json file setup with references to Angular and Office typings. It would be helpful to include the reference to the /typings/tsd.d.ts file in all .js files so that developers can benefit of intellisense even if they're coding in plain JavaScript.

Automate "bower install" after "npm install"

I think you should add the following snippet into the package.json file to automatically run bower install after running npm install. I know this is done when you first use the generator, but if I do a fresh clone of a project that has used the generator and run npm install, I'll be left without any of my bower components. It's a pretty simple addition and I can submit a PR if you think this would be beneficial.

"scripts": {
    "postinstall": "node_modules/.bin/bower install"
  }

Update docs for developers, testing & contributors

Update the /docs folder with new content:

  • update readme.md
  • move & refactor the CONTRIBUTING.md doc to docs (rename to contributing.md)
  • add details on CLA
  • add developer-guide.md
  • add developer-testing.md
  • revamp example docs
  • revamp docs/readme.md
  • add instructions on forking, resyncing & committing

Make localhost "safe"

I'm unfamiliar with SSL certificates and the like, but is there anyway to make the server started by Gulp "safe"? Unless you go to the index.html page in a browser and accept that it's unsafe, the Add-in fails to render. There might be no way around this, but it would be nice to not have to explicitly have to give instructions to go and accept the SSL certificate in our READMEs for samples and stuff.

Simplify bootstrapping add-ins

I believe we could simplify bootstrapping the add-in by removing jQuery from app.module.js and slightly changing the HTML structure in index.html.

Add product options for task pane & contact add-in options

When creating a Office Task Pane Add-in or Content Add-in, prompt the user for the Office client products that the add-in is for:

  • Word
  • Excel
  • PowerPoint
  • OneNote
  • ...

This should be an extra question and allow 1 or more selections, but this should only show when the user picks one of these two add-in types.

HighResolutionIconUrl invalid on creation

Getting an error in uploading the manifest.xml when using yo office.

"This app can't be installed. The HighResolutionIconUrl value '[Icon URL]' isn't a corectly formatted URL."

Although it's great we use these values. I think its better to actually include a icon placeholder in the project and reference that with https://localhost:8443/ url as we are hard coding that anyway. Less steps to getting it running that way.

Including additional Gulp tasks to support releases & deployment

@andrewconnell, @jthake: What do you guys think about including additional Gulps tasks in the generated gulpfile.js to support releases, such as copy the add-in files to be deployed to a separate folder (eg. dist), minifying scripts and CSS and bumping the version number in the manifest.xml and package.json? How about taking a look at the ability to upload the manifest.xml to the App Catalog? The main goal of these tasks would be to support developers in the deployment and release of projects built with the generator.

Log exception when one of the tests fails

When one of the tests in $ gulp test breaks at the end you get the following error:

/Users/usr/github/generator-office/gulpfile.js:129
  $.log(err.toString());
    ^
TypeError: undefined is not a function
    at Stream.handleError (/Users/usr/github/generator-office/gulpfile.js:129:5)
    at Stream.emit (events.js:129:20)

Shouldn't https://github.com/OfficeDev/generator-office/blob/master/gulpfile.js#L129 be referring to the function defined in https://github.com/OfficeDev/generator-office/blob/master/gulpfile.js#L113 (so calling log rather than $.log)?

Invalid reference to scripts/jquery.fabric.min.js in generated appread files

For a Mail Add-in the appread/index.html file contains an invalid reference to the jquery.fabric.min.js file. The generated reference is scripts/jquery.fabric.min.js while it should be ../scripts/jquery.fabric.min.js to point to the correct location of the JavaScript file. The same invalid path is also used in references to content/fabric.min.css and content/fabric.components.min.css.

Intellisense for manifest.xml

I noticed that if you put the XSD with the OfficeApp schema in the same directory as manifest.xml, Visual Studio Code gives you intellisense for the manifest's XML. I can imagine this being very useful for editing it. I'm not sure if this behavior is specific for VSCode but if there are more editors supporting it, we could include the XSD with the generated project to simplify working with the manifest.xml.

Add Mail Add-in Options for Mail & Calendar Read & Compose

Currently the generator builds mail read & compose forms. When picking a mail add-in, the generator should instead then prompt the user for four options, of which they can pick one or more:

  • Mail Compose Form
  • Mail Read Form
  • Calendar Compose Form
  • Calendar Read Form

When released - add Office Fabric UI

When it's publicly released, include the Office Fabric UI as a dependency to all add-ins as using both bower & (if provided) the public CDN's.

Include both references in the index.html file but comment out the local bower references (default to CDN).

Add support for add-in commands to mail add-in

We should show off the new add-in commands in the add-in that's generated.

http://blogs.msdn.com/b/exchangedev/archive/2015/08/31/introducing-add-in-commands.aspx
http://blogs.msdn.com/b/exchangedev/archive/2015/09/01/building-add-ins-with-commands.aspx

I have a demo add-in that shows the three command button types that's a straight HTML/CSS/JS project. It also uses Fabric: https://github.com/jasonjoh/command-demo

I'd propose using this in place of the demo add-in that's there now. We could prompt the user to include the command button types they are interested in and only include those types. I'm working on a prototype in my fork of this repo, I'll update once I have something to look at.

Generator seems to hang waiting for user to hit Enter to finish

Using generator on Windows 10 in the following manner:

yo office
? Project name (display name): yotest2
? Root folder of project? Default to current directory
 (C:\Users\jasonjoh\Source\Repos\mail-addins\yotest2), or specify relative path
  from current (src / public):
? Office project type: Mail Add-in (read & compose forms)
? Technology to use: HTML, CSS & JavaScript

After the generator does its work, and the final line is output:

microsoft.office.js#2b215a298b bower_components\microsoft.office.js

The generator seems to hang, with the cursor just flashing. If you press Enter, it will exit.

Ideally the need to hit Enter can be removed, but if it can't, the tool should tell the user they need to hit Enter to exit.

Generator creates invalid manifest.xml file

The generator creates an invalid add-in manifest file. If you try to upload the manifest.xml directly after generating the add-in, the Apps for Office catalog in SharePoint Online will consider the manifest as invalid. In order to fix the issue you need to remove the empty <SupportUrl/> element from manifest.xml. After that you will be able to upload the manifest.xml file as expected.

When generating an add-in in a directory relative to current some files get placed in the current directory rather than the specified project root directory

When generating an add-in in a directory relative to current the following structure is generated (based on a Task Pane Add-in built using HTML):

.
|- bower.json
|- gulpfile.js
|- jsconfig.json
|- manifest.xml
|- node_modules
|- package.json
|- tsd.json
|- [project root directory]
|  |- app
|  |- bower_components
|  |- content
|  |- images
|  |- scripts

Shouldn't all files be placed in the project root directory which is what you get when you choose the current directory to be the project root directory, ie:

[project root directory]
|- bower.json
|- gulpfile.js
|- jsconfig.json
|- manifest.xml
|- node_modules
|- package.json
|- tsd.json
|- app
|- bower_components
|- content
|- images
|- scripts

gulp run-yo does not work on Windows due to pathing issues

The problem seems to be right here in gulpfile.js:

  spawn('node',
    [
      '--debug',
      path.join(which.sync('yo'), '../../', 'lib/node_modules/yo/lib/cli.js'),
      'office',
      ' --skip-install'
    ], {
      stdio: 'inherit'
    });

This ends up looking for cli.js in the wrong place:

C:\Users\alexpark\OneDrive\fun\generator-office>gulp run-yo
[21:34:11] Using gulpfile ~\OneDrive\fun\generator-office\gulpfile.js
[21:34:11] Starting 'run-yo'...
[21:34:11] BE AWARE!!! - Running this with default options will scaffold the project in the generator's source folder.
[21:34:11] Finished 'run-yo' after 15 ms
Debugger listening on port 5858
module.js:338
    throw err;
          ^
Error: Cannot find module 'C:\Users\alexpark\AppData\Roaming\lib\node_modules\yo\lib\cli.js'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Changing path.join(which.sync('yo'), '../../', 'lib/node_modules/yo/lib/cli.js'), to path.join(which.sync('yo'), '../../', 'npm/node_modules/yo/lib/cli.js'), works, but a proper fix would switch based on the OS or maybe programmatically find the npm path?

Angular app lists the directory contents instead of the actual app

When browsing to the root of the app, I see the contents of the root folder.
image

However, I think what you're trying to show is something like the following image
image

If this is right, you just need to add ng-app and ng-controller directives to index.html

<html ng-app="officeAddin">
...
<body id="container" ng-controller="homeController">

and set directoryListing: false in gulpfile.js

All script tags referring to application/javascript

In the index.html file all JavaScript references specify the script type as application/javascript. Shouldn't it be text/javascript instead which is the default script type in HTML5? If the script type will be changed consider removing it altogether as mentioned in issue #40.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.