<commit_before>import { parse } from 'compiler/parser/index'
import { extend } from 'shared/util'
import { baseOptions } from 'web/compiler/index'

describe('parser', () => {
  it('simple element', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.tag).toBe('h1')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].text).toBe('hello world')
  })

  it('interpolation in element', () => {
    const ast = parse('
{{msg}}
', baseOptions)
    expect(ast.tag).toBe('h1')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].expression).toBe('_s(msg)')
  })

  it('child elements', () => {
    const ast = parse('

hello world

', baseOptions)
    expect(ast.tag).toBe('ul')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('li')
    expect(ast.children[0].plain).toBe(true)
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('unary element', () => {
    const ast = parse('
', baseOptions)
    expect(ast.tag).toBe('hr')
    expect(ast.plain).toBe(true)
    expect(ast.children.length).toBe(0)
  })

  it('svg element', () => {
    const ast = parse('<svg><text>hello world</text></svg>', baseOptions)
    expect(ast.tag).toBe('svg')
    expect(ast.ns).toBe('svg')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('text')
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('camelCase element', () => {
    const ast = parse('<MyComponent>
hello world
</MyComponent>', baseOptions)
    expect(ast.tag).toBe('MyComponent')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('p')
    expect(ast.children[0].plain).toBe(true)
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('forbidden element', () => {
    // style
    const styleAst = parse('', baseOptions)
    expect(styleAst.tag).toBe('style')
    expect(styleAst.plain).toBe(true)
    expect(styleAst.forbidden).toBe(true)
    expect(styleAst.children[0].text).toBe('error { color: red; }')
    expect('Templates should only be responsible for mapping the state').toHaveBeenWarned()
    // script
    const scriptAst = parse('', baseOptions)
    expect(scriptAst.tag).toBe('script')
    expect(scriptAst.plain).toBe(false)
    expect(scriptAst.forbidden).toBe(true)
    expect(scriptAst.children[0].text).toBe('alert("hello world!")')
    expect('Templates should only be responsible for mapping the state').toHaveBeenWarned()
  })

  it('not contain root element', () => {
    parse('hello world', baseOptions)
    expect('Component template should contain exactly one root element').toHaveBeenWarned()
  })

  it('warn multiple root elements', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

').toHaveBeenWarned()
  })

  it('not warn 2 root elements with v-if and v-else', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

')
      .not.toHaveBeenWarned()
  })

  it('warn 2 root elements with v-if', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

')
      .toHaveBeenWarned()
  })

  it('warn 3 root elements with v-if and v-else on first 2', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

')
      .toHaveBeenWarned()
  })

  it('warn 2 root elements with v-if and v-else with v-for on 2nd', () => {
    parse('

', baseOptions)
    expect('Cannot use v-for on stateful component root element because it renders multiple elements:\n

')
      .toHaveBeenWarned()
  })

  it('warn <template> as root element', () => {
    parse('<template></template>', baseOptions)
    expect('Cannot use <template> as component root element').toHaveBeenWarned()
  })

  it('warn <slot> as root element', () => {
    parse('<slot></slot>', baseOptions)
    expect('Cannot use <slot> as component root element').toHaveBeenWarned()
  })

  it('warn v-for on root element', () => {
    parse('

', baseOptions)
    expect('Cannot use v-for on stateful component root element').toHaveBeenWarned()
  })

  it('v-pre directive', () => {
    const ast = parse('

{{msg}}

', baseOptions)
    expect(ast.pre).toBe(true)
    expect(ast.attrs[0].name).toBe('id')
    expect(ast.attrs[0].value).toBe('"message1"')
    expect(ast.children[0].children[0].text).toBe('{{msg}}')
  })

  it('v-for directive basic syntax', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
  })

  it('v-for directive iteration syntax', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
    expect(liAst.iterator1).toBe('index')
    expect(liAst.iterator2).toBeUndefined()
  })

  it('v-for directive iteration syntax (multiple)', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
    expect(liAst.iterator1).toBe('key')
    expect(liAst.iterator2).toBe('index')
  })

  it('v-for directive key', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
    expect(liAst.key).toBe('item.uid')
  })

  it('v-for directive invalid syntax', () => {
    parse('

', baseOptions)
    expect('Invalid v-for expression').toHaveBeenWarned()
  })

  it('v-if directive syntax', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.if).toBe('show')
  })

  it('v-else directive syntax', () => {
    const ast = parse('

hello

world

', baseOptions)
    const ifAst = ast.children[0]
    const elseAst = ifAst.elseBlock
    expect(elseAst.else).toBe(true)
    expect(elseAst.children[0].text).toBe('world')
    expect(elseAst.parent).toBe(ast)
  })

  it('v-else directive invalid syntax', () => {
    parse('

world

', baseOptions)
    expect('v-else used on element').toHaveBeenWarned()
  })

  it('v-once directive syntax', () => {
    const ast = parse('
world
', baseOptions)
    expect(ast.once).toBe(true)
  })

  it('slot tag single syntax', () => {
    const ast = parse('<slot></slot>', baseOptions)
    expect(ast.tag).toBe('slot')
    expect(ast.slotName).toBeUndefined()
  })

  it('slot tag namped syntax', () => {
    const ast = parse('<slot name="one">hello world</slot>', baseOptions)
    expect(ast.tag).toBe('slot')
    expect(ast.slotName).toBe('"one"')
  })

  it('slot target', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.slotTarget).toBe('"one"')
  })

  it('component properties', () => {
    const ast = parse('<my-component :msg="hello"></my-component>', baseOptions)
    expect(ast.attrs[0].name).toBe('msg')
    expect(ast.attrs[0].value).toBe('hello')
  })

  it('component "is" attribute', () => {
    const ast = parse('<my-component is="component1"></my-component>', baseOptions)
    expect(ast.component).toBe('"component1"')
  })

  it('component "inline-template" attribute', () => {
    const ast = parse('<my-component inline-template>hello world</my-component>', baseOptions)
    expect(ast.inlineTemplate).toBe(true)
  })

  it('class binding', () => {
    // static
    const ast1 = parse('
hello world
', baseOptions)
    expect(ast1.staticClass).toBe('"class1"')
    // dynamic
    const ast2 = parse('
hello world
', baseOptions)
    expect(ast2.classBinding).toBe('class1')
    // interpolation warning
    parse('
hello world
', baseOptions)
    expect('Interpolation inside attributes has been deprecated').toHaveBeenWarned()
  })

  it('style binding', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.styleBinding).toBe('error')
  })

  it('attribute with v-bind', () => {
    const ast = parse('<input type="text" name="field1" :value="msg">', baseOptions)
    expect(ast.attrsList[0].name).toBe('type')
    expect(ast.attrsList[0].value).toBe('text')
    expect(ast.attrsList[1].name).toBe('name')
    expect(ast.attrsList[1].value).toBe('field1')
    expect(ast.attrsMap['type']).toBe('text')
    expect(ast.attrsMap['name']).toBe('field1')
    expect(ast.attrs[0].name).toBe('type')
    expect(ast.attrs[0].value).toBe('"text"')
    expect(ast.attrs[1].name).toBe('name')
    expect(ast.attrs[1].value).toBe('"field1"')
    expect(ast.props[0].name).toBe('value')
    expect(ast.props[0].value).toBe('msg')
  })

  it('attribute with v-on', () => {
    const ast = parse('<input type="text" name="field1" :value="msg" @input="onInput">', baseOptions)
    expect(ast.events.input.value).toBe('onInput')
  })

  it('attribute with directive', () => {
    const ast = parse('<input type="text" name="field1" :value="msg" v-validate:field1="required">', baseOptions)
    expect(ast.directives[0].name).toBe('validate')
    expect(ast.directives[0].value).toBe('required')
    expect(ast.directives[0].arg).toBe('field1')
  })

  it('attribute with modifiered directive', () => {
    const ast = parse('<input type="text" name="field1" :value="msg" v-validate.on.off>', baseOptions)
    expect(ast.directives[0].modifiers.on).toBe(true)
    expect(ast.directives[0].modifiers.off).toBe(true)
  })

  it('literal attribute', () => {
    // basic
    const ast1 = parse('<input type="text" name="field1" value="hello world">', baseOptions)
    expect(ast1.attrsList[0].name).toBe('type')
    expect(ast1.attrsList[0].value).toBe('text')
    expect(ast1.attrsList[1].name).toBe('name')
    expect(ast1.attrsList[1].value).toBe('field1')
    expect(ast1.attrsList[2].name).toBe('value')
    expect(ast1.attrsList[2].value).toBe('hello world')
    expect(ast1.attrsMap['type']).toBe('text')
    expect(ast1.attrsMap['name']).toBe('field1')
    expect(ast1.attrsMap['value']).toBe('hello world')
    expect(ast1.attrs[0].name).toBe('type')
    expect(ast1.attrs[0].value).toBe('"text"')
    expect(ast1.attrs[1].name).toBe('name')
    expect(ast1.attrs[1].value).toBe('"field1"')
    expect(ast1.attrs[2].name).toBe('value')
    expect(ast1.attrs[2].value).toBe('"hello world"')
    // interpolation warning
    parse('<input type="text" name="field1" value="{{msg}}">', baseOptions)
    expect('Interpolation inside attributes has been deprecated').toHaveBeenWarned()
  })

  it('duplicate attribute', () => {
    parse('
hello world
', baseOptions)
    expect('duplicate attribute').toHaveBeenWarned()
  })

  it('custom delimiter', () => {
    const ast = parse('
{msg}
', extend({ delimiters: ['{', '}'] }, baseOptions))
    expect(ast.children[0].expression).toBe('_s(msg)')
  })

  it('not specified getTagNamespace option', () => {
    const options = extend({}, baseOptions)
    delete options.getTagNamespace
    const ast = parse('<svg><text>hello world</text></svg>', options)
    expect(ast.tag).toBe('svg')
    expect(ast.ns).toBeUndefined()
  })

  it('not specified mustUseProp', () => {
    const options = extend({}, baseOptions)
    delete options.mustUseProp
    const ast = parse('<input type="text" name="field1" :value="msg">', options)
    expect(ast.props).toBeUndefined()
  })

  it('pre/post transforms', () => {
    const options = extend({}, baseOptions)
    const spy1 = jasmine.createSpy('preTransform')
    const spy2 = jasmine.createSpy('postTransform')
    options.modules = options.modules.concat([{
      preTransformNode (el) {
        spy1(el.tag)
      },
      postTransformNode (el) {
        expect(el.attrs.length).toBe(1)
        spy2(el.tag)
      }
    }])
    parse('', options)
    expect(spy1).toHaveBeenCalledWith('img')
    expect(spy2).toHaveBeenCalledWith('img')
  })

  it('preserve whitespace in
 tag', function () {
    const options = extend({}, baseOptions)
    const ast = parse('
  \nhi\n
', options)
    const code = ast.children[0]
    expect(code.children[0].type).toBe(3)
    expect(code.children[0].text).toBe('  \n')
    expect(code.children[2].type).toBe(3)
    expect(code.children[2].text).toBe('\n  ')
  })
})
<commit_msg>test <template> key warning, fix coverage<commit_after>import { parse } from 'compiler/parser/index'
import { extend } from 'shared/util'
import { baseOptions } from 'web/compiler/index'

describe('parser', () => {
  it('simple element', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.tag).toBe('h1')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].text).toBe('hello world')
  })

  it('interpolation in element', () => {
    const ast = parse('
{{msg}}
', baseOptions)
    expect(ast.tag).toBe('h1')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].expression).toBe('_s(msg)')
  })

  it('child elements', () => {
    const ast = parse('

hello world

', baseOptions)
    expect(ast.tag).toBe('ul')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('li')
    expect(ast.children[0].plain).toBe(true)
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('unary element', () => {
    const ast = parse('
', baseOptions)
    expect(ast.tag).toBe('hr')
    expect(ast.plain).toBe(true)
    expect(ast.children.length).toBe(0)
  })

  it('svg element', () => {
    const ast = parse('<svg><text>hello world</text></svg>', baseOptions)
    expect(ast.tag).toBe('svg')
    expect(ast.ns).toBe('svg')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('text')
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('camelCase element', () => {
    const ast = parse('<MyComponent>
hello world
</MyComponent>', baseOptions)
    expect(ast.tag).toBe('MyComponent')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('p')
    expect(ast.children[0].plain).toBe(true)
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('forbidden element', () => {
    // style
    const styleAst = parse('', baseOptions)
    expect(styleAst.tag).toBe('style')
    expect(styleAst.plain).toBe(true)
    expect(styleAst.forbidden).toBe(true)
    expect(styleAst.children[0].text).toBe('error { color: red; }')
    expect('Templates should only be responsible for mapping the state').toHaveBeenWarned()
    // script
    const scriptAst = parse('', baseOptions)
    expect(scriptAst.tag).toBe('script')
    expect(scriptAst.plain).toBe(false)
    expect(scriptAst.forbidden).toBe(true)
    expect(scriptAst.children[0].text).toBe('alert("hello world!")')
    expect('Templates should only be responsible for mapping the state').toHaveBeenWarned()
  })

  it('not contain root element', () => {
    parse('hello world', baseOptions)
    expect('Component template should contain exactly one root element').toHaveBeenWarned()
  })

  it('warn multiple root elements', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

').toHaveBeenWarned()
  })

  it('not warn 2 root elements with v-if and v-else', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

')
      .not.toHaveBeenWarned()
  })

  it('warn 2 root elements with v-if', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

')
      .toHaveBeenWarned()
  })

  it('warn 3 root elements with v-if and v-else on first 2', () => {
    parse('

', baseOptions)
    expect('Component template should contain exactly one root element:\n\n

')
      .toHaveBeenWarned()
  })

  it('warn 2 root elements with v-if and v-else with v-for on 2nd', () => {
    parse('

', baseOptions)
    expect('Cannot use v-for on stateful component root element because it renders multiple elements:\n

')
      .toHaveBeenWarned()
  })

  it('warn <template> as root element', () => {
    parse('<template></template>', baseOptions)
    expect('Cannot use <template> as component root element').toHaveBeenWarned()
  })

  it('warn <slot> as root element', () => {
    parse('<slot></slot>', baseOptions)
    expect('Cannot use <slot> as component root element').toHaveBeenWarned()
  })

  it('warn v-for on root element', () => {
    parse('

', baseOptions)
    expect('Cannot use v-for on stateful component root element').toHaveBeenWarned()
  })

  it('warn <template> key', () => {
    parse('
<template v-for="i in 10" :key="i"></template>
', baseOptions)
    expect('<template> cannot be keyed').toHaveBeenWarned()
  })

  it('v-pre directive', () => {
    const ast = parse('

{{msg}}

', baseOptions)
    expect(ast.pre).toBe(true)
    expect(ast.attrs[0].name).toBe('id')
    expect(ast.attrs[0].value).toBe('"message1"')
    expect(ast.children[0].children[0].text).toBe('{{msg}}')
  })

  it('v-for directive basic syntax', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
  })

  it('v-for directive iteration syntax', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
    expect(liAst.iterator1).toBe('index')
    expect(liAst.iterator2).toBeUndefined()
  })

  it('v-for directive iteration syntax (multiple)', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
    expect(liAst.iterator1).toBe('key')
    expect(liAst.iterator2).toBe('index')
  })

  it('v-for directive key', () => {
    const ast = parse('

', baseOptions)
    const liAst = ast.children[0]
    expect(liAst.for).toBe('items')
    expect(liAst.alias).toBe('item')
    expect(liAst.key).toBe('item.uid')
  })

  it('v-for directive invalid syntax', () => {
    parse('

', baseOptions)
    expect('Invalid v-for expression').toHaveBeenWarned()
  })

  it('v-if directive syntax', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.if).toBe('show')
  })

  it('v-else directive syntax', () => {
    const ast = parse('

hello

world

', baseOptions)
    const ifAst = ast.children[0]
    const elseAst = ifAst.elseBlock
    expect(elseAst.else).toBe(true)
    expect(elseAst.children[0].text).toBe('world')
    expect(elseAst.parent).toBe(ast)
  })

  it('v-else directive invalid syntax', () => {
    parse('

world

', baseOptions)
    expect('v-else used on element').toHaveBeenWarned()
  })

  it('v-once directive syntax', () => {
    const ast = parse('
world
', baseOptions)
    expect(ast.once).toBe(true)
  })

  it('slot tag single syntax', () => {
    const ast = parse('<slot></slot>', baseOptions)
    expect(ast.tag).toBe('slot')
    expect(ast.slotName).toBeUndefined()
  })

  it('slot tag namped syntax', () => {
    const ast = parse('<slot name="one">hello world</slot>', baseOptions)
    expect(ast.tag).toBe('slot')
    expect(ast.slotName).toBe('"one"')
  })

  it('slot target', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.slotTarget).toBe('"one"')
  })

  it('component properties', () => {
    const ast = parse('<my-component :msg="hello"></my-component>', baseOptions)
    expect(ast.attrs[0].name).toBe('msg')
    expect(ast.attrs[0].value).toBe('hello')
  })

  it('component "is" attribute', () => {
    const ast = parse('<my-component is="component1"></my-component>', baseOptions)
    expect(ast.component).toBe('"component1"')
  })

  it('component "inline-template" attribute', () => {
    const ast = parse('<my-component inline-template>hello world</my-component>', baseOptions)
    expect(ast.inlineTemplate).toBe(true)
  })

  it('class binding', () => {
    // static
    const ast1 = parse('
hello world
', baseOptions)
    expect(ast1.staticClass).toBe('"class1"')
    // dynamic
    const ast2 = parse('
hello world
', baseOptions)
    expect(ast2.classBinding).toBe('class1')
    // interpolation warning
    parse('
hello world
', baseOptions)
    expect('Interpolation inside attributes has been deprecated').toHaveBeenWarned()
  })

  it('style binding', () => {
    const ast = parse('
hello world
', baseOptions)
    expect(ast.styleBinding).toBe('error')
  })

  it('attribute with v-bind', () => {
    const ast = parse('<input type="text" name="field1" :value="msg">', baseOptions)
    expect(ast.attrsList[0].name).toBe('type')
    expect(ast.attrsList[0].value).toBe('text')
    expect(ast.attrsList[1].name).toBe('name')
    expect(ast.attrsList[1].value).toBe('field1')
    expect(ast.attrsMap['type']).toBe('text')
    expect(ast.attrsMap['name']).toBe('field1')
    expect(ast.attrs[0].name).toBe('type')
    expect(ast.attrs[0].value).toBe('"text"')
    expect(ast.attrs[1].name).toBe('name')
    expect(ast.attrs[1].value).toBe('"field1"')
    expect(ast.props[0].name).toBe('value')
    expect(ast.props[0].value).toBe('msg')
  })

  it('attribute with v-on', () => {
    const ast = parse('<input type="text" name="field1" :value="msg" @input="onInput">', baseOptions)
    expect(ast.events.input.value).toBe('onInput')
  })

  it('attribute with directive', () => {
    const ast = parse('<input type="text" name="field1" :value="msg" v-validate:field1="required">', baseOptions)
    expect(ast.directives[0].name).toBe('validate')
    expect(ast.directives[0].value).toBe('required')
    expect(ast.directives[0].arg).toBe('field1')
  })

  it('attribute with modifiered directive', () => {
    const ast = parse('<input type="text" name="field1" :value="msg" v-validate.on.off>', baseOptions)
    expect(ast.directives[0].modifiers.on).toBe(true)
    expect(ast.directives[0].modifiers.off).toBe(true)
  })

  it('literal attribute', () => {
    // basic
    const ast1 = parse('<input type="text" name="field1" value="hello world">', baseOptions)
    expect(ast1.attrsList[0].name).toBe('type')
    expect(ast1.attrsList[0].value).toBe('text')
    expect(ast1.attrsList[1].name).toBe('name')
    expect(ast1.attrsList[1].value).toBe('field1')
    expect(ast1.attrsList[2].name).toBe('value')
    expect(ast1.attrsList[2].value).toBe('hello world')
    expect(ast1.attrsMap['type']).toBe('text')
    expect(ast1.attrsMap['name']).toBe('field1')
    expect(ast1.attrsMap['value']).toBe('hello world')
    expect(ast1.attrs[0].name).toBe('type')
    expect(ast1.attrs[0].value).toBe('"text"')
    expect(ast1.attrs[1].name).toBe('name')
    expect(ast1.attrs[1].value).toBe('"field1"')
    expect(ast1.attrs[2].name).toBe('value')
    expect(ast1.attrs[2].value).toBe('"hello world"')
    // interpolation warning
    parse('<input type="text" name="field1" value="{{msg}}">', baseOptions)
    expect('Interpolation inside attributes has been deprecated').toHaveBeenWarned()
  })

  it('duplicate attribute', () => {
    parse('
hello world
', baseOptions)
    expect('duplicate attribute').toHaveBeenWarned()
  })

  it('custom delimiter', () => {
    const ast = parse('
{msg}
', extend({ delimiters: ['{', '}'] }, baseOptions))
    expect(ast.children[0].expression).toBe('_s(msg)')
  })

  it('not specified getTagNamespace option', () => {
    const options = extend({}, baseOptions)
    delete options.getTagNamespace
    const ast = parse('<svg><text>hello world</text></svg>', options)
    expect(ast.tag).toBe('svg')
    expect(ast.ns).toBeUndefined()
  })

  it('not specified mustUseProp', () => {
    const options = extend({}, baseOptions)
    delete options.mustUseProp
    const ast = parse('<input type="text" name="field1" :value="msg">', options)
    expect(ast.props).toBeUndefined()
  })

  it('pre/post transforms', () => {
    const options = extend({}, baseOptions)
    const spy1 = jasmine.createSpy('preTransform')
    const spy2 = jasmine.createSpy('postTransform')
    options.modules = options.modules.concat([{
      preTransformNode (el) {
        spy1(el.tag)
      },
      postTransformNode (el) {
        expect(el.attrs.length).toBe(1)
        spy2(el.tag)
      }
    }])
    parse('', options)
    expect(spy1).toHaveBeenCalledWith('img')
    expect(spy2).toHaveBeenCalledWith('img')
  })

  it('preserve whitespace in
 tag', function () {
    const options = extend({}, baseOptions)
    const ast = parse('
  \nhi\n
', options)
    const code = ast.children[0]
    expect(code.children[0].type).toBe(3)
    expect(code.children[0].text).toBe('  \n')
    expect(code.children[2].type).toBe(3)
    expect(code.children[2].text).toBe('\n  ')
  })
})
<|endoftext|>


<commit_before>/********************************************************** {COPYRIGHT-TOP} ****
 * Licensed Materials - Property of IBM
 *
 * (C) Copyright IBM Corp. 2014 All Rights Reserved
 *
 * US Government Users Restricted Rights - Use, duplication, or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 ********************************************************* {COPYRIGHT-END} ****/
/*jshint expr: true*/

var path = require('path');
var appHome = path.join(process.cwd(), 'app');
global.appHome = appHome;

var rewire = require('rewire');
var chai = require('chai');
var expect = chai.expect;

chai.config.includeStack = false;

var rewire_revert = false;

describe('Application Model', function() {

  var applicationModel = rewire('../../../api/models/application');

  before(function() {
    // mock DB results using rewire
    applicationModel.__set__('APPS', [{
      id: 8888,
      name: 'Cool Beans',
      lastUpdated: '2015-10-09T04:04:00',
      status: 'online'
    }, {
      id: 9999,
      name: 'My Test App',
      lastUpdated: '2015-11-09T14:14:00',
      status: 'online'
    }]);
  });

  describe("application model", function() {
    describe("#getAllApplications()", function() {
      it("respond with all applications", function() {
        var apps = applicationModel.getAllApplications();
        expect(apps.length).to.equal(2);
      });
    });

    describe("#getApplicationById", function() {
      it("respond with matching application", function() {
        var apps = applicationModel.getApplicationById(8888);
        expect(apps.id).to.equal(8888);
      });
    });
  });
});
<commit_msg>fail test<commit_after>/********************************************************** {COPYRIGHT-TOP} ****
 * Licensed Materials - Property of IBM
 *
 * (C) Copyright IBM Corp. 2014 All Rights Reserved
 *
 * US Government Users Restricted Rights - Use, duplication, or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 ********************************************************* {COPYRIGHT-END} ****/
/*jshint expr: true*/

var path = require('path');
var appHome = path.join(process.cwd(), 'app');
global.appHome = appHome;

var rewire = require('rewire');
var chai = require('chai');
var expect = chai.expect;

chai.config.includeStack = false;

var rewire_revert = false;

describe('Application Model', function() {

  var applicationModel = rewire('../../../api/models/application');

  before(function() {
    // mock DB results using rewire
    applicationModel.__set__('APPS', [{
      id: 8889,
      name: 'Cool Beans',
      lastUpdated: '2015-10-09T04:04:00',
      status: 'online'
    }, {
      id: 9999,
      name: 'My Test App',
      lastUpdated: '2015-11-09T14:14:00',
      status: 'online'
    }]);
  });

  describe("application model", function() {
    describe("#getAllApplications()", function() {
      it("respond with all applications", function() {
        var apps = applicationModel.getAllApplications();
        expect(apps.length).to.equal(2);
      });
    });

    describe("#getApplicationById", function() {
      it("respond with matching application", function() {
        var apps = applicationModel.getApplicationById(8888);
        expect(apps.id).to.equal(8888);
      });
    });
  });
});
<|endoftext|>


<commit_before>/**
 * WordPress dependencies
 */
import { deactivatePlugin, activatePlugin } from '@wordpress/e2e-test-utils';

describe( 'Plugin Activation Notice', () => {
	beforeEach( async () => {
		await deactivatePlugin( 'site-kit-by-google' );
		await activatePlugin( 'e2e-tests-gcp-credentials-plugin' );
	} );

	afterEach( async () => {
		await deactivatePlugin( 'e2e-tests-gcp-credentials-plugin' );
		await activatePlugin( 'site-kit-by-google' );
	} );

	it( 'Should be displayed', async () => {
		await activatePlugin( 'site-kit-by-google' );

		await page.waitForSelector( '.googlesitekit-activation' );

		await expect( page ).toMatchElement( 'h3.googlesitekit-activation__title', { text: 'Congratulations, the Site Kit plugin is now activated.' } );

		await deactivatePlugin( 'site-kit-by-google' );
	} );

	it( 'Should lead you to the setup wizard', async () => {
		await activatePlugin( 'site-kit-by-google' );

		await page.waitForSelector( '.googlesitekit-activation' );

		await expect( page ).toMatchElement( '.googlesitekit-activation__button', { text: 'Start Setup' } );

		await page.click( '.googlesitekit-activation__button' );
		await page.waitForSelector( '.googlesitekit-wizard-step__title' );

		// Ensure we're on the first step.
		await expect( page ).toMatchElement( '.googlesitekit-wizard-progress-step__number--inprogress', { text: '1' } );
	} );
} );
<commit_msg>refactor site kit plugin activation<commit_after>/**
 * WordPress dependencies
 */
import { deactivatePlugin, activatePlugin } from '@wordpress/e2e-test-utils';

/**
 * Activation helpers are only necessary pre-1.0 release.
 * WordPress populates the `data-slug` attribute from the
 * `slug` returned by the wp.org plugin API. For plugins
 * that are not available on the .org repo, the slug will be
 * generated from the plugin's name.
 *
 * For this reason, we fallback to the title-based slug if the
 * expected "official" slug is not found.
 *
 * Once the plugin is publicly available, these helpers can be removed
 * and consuming code can use `google-site-kit` variations in their places.
 */

const activateSiteKit = async () => {
	try {
		await activatePlugin( 'google-site-kit' );
	} catch {
		await activatePlugin( 'site-kit-by-google' );
	}
};

const deactivateSiteKit = async () => {
	try {
		await deactivatePlugin( 'google-site-kit' );
	} catch {
		await deactivatePlugin( 'site-kit-by-google' );
	}
};

describe( 'Plugin Activation Notice', () => {
	beforeEach( async () => {
		await deactivateSiteKit();
		await activatePlugin( 'e2e-tests-gcp-credentials-plugin' );
	} );

	afterEach( async () => {
		await deactivatePlugin( 'e2e-tests-gcp-credentials-plugin' );
		await activateSiteKit();
	} );

	it( 'Should be displayed', async () => {
		await activateSiteKit();

		await page.waitForSelector( '.googlesitekit-activation' );

		await expect( page ).toMatchElement( 'h3.googlesitekit-activation__title', { text: 'Congratulations, the Site Kit plugin is now activated.' } );

		await deactivateSiteKit();
	} );

	it( 'Should lead you to the setup wizard', async () => {
		await activateSiteKit();

		await page.waitForSelector( '.googlesitekit-activation' );

		await expect( page ).toMatchElement( '.googlesitekit-activation__button', { text: 'Start Setup' } );

		await page.click( '.googlesitekit-activation__button' );
		await page.waitForSelector( '.googlesitekit-wizard-step__title' );

		// Ensure we're on the first step.
		await expect( page ).toMatchElement( '.googlesitekit-wizard-progress-step__number--inprogress', { text: '1' } );
	} );
} );
<|endoftext|>


<commit_before>(function( $ ) {

module( "accordion: options", accordionSetupTeardown() );

test( "{ active: default }", function() {
	var ac = $( "#list1" ).accordion();
	equals( ac.accordion( "option", "active" ), 0 );
	state( ac, 1, 0, 0 );
});

test( "{ active: false }", function() {
	var ac = $( "#list1" ).accordion({
		active: false,
		collapsible: true
	});
	state( ac, 0, 0, 0 );
	equals( ac.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
	equals( ac.accordion( "option", "active" ), false );

	ac.accordion( "option", "collapsible", false );
	state( ac, 1, 0, 0 );
	equals( ac.accordion( "option", "active" ), 0 );

	ac.accordion( "destroy" );
	ac.accordion({
		active: false
	});
	state( ac, 1, 0, 0 );
	strictEqual( ac.accordion( "option", "active" ), 0 );
});

test( "{ active: Number }", function() {
	var ac = $( "#list1" ).accordion({
		active: 2
	});
	equals( ac.accordion( "option", "active" ), 2 );
	state( ac, 0, 0, 1 );

	ac.accordion( "option", "active", 0 );
	equals( ac.accordion( "option", "active" ), 0 );
	state( ac, 1, 0, 0 );

	ac.find( ".ui-accordion-header" ).eq( 1 ).click();
	equals( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );

	ac.accordion( "option", "active", 10 );
	equals( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );
});

if ( $.uiBackCompat === false ) {
	test( "{ active: -Number }", function() {
		var ac = $( "#list1" ).accordion({
			active: -1
		});
		equals( ac.accordion( "option", "active" ), 2 );
		state( ac, 0, 0, 1 );

		ac.accordion( "option", "active", -2 );
		equals( ac.accordion( "option", "active" ), 1 );
		state( ac, 0, 1, 0 );

		ac.accordion( "option", "active", -10 );
		equals( ac.accordion( "option", "active" ), 1 );
		state( ac, 0, 1, 0 );

		ac.accordion( "option", "active", -3 );
		equals( ac.accordion( "option", "active" ), 0 );
		state( ac, 1, 0, 0 );
	});
}

// TODO: add animation tests

test( "{ collapsible: false }", function() {
	var ac = $( "#list1" ).accordion({
		active: 1
	});
	ac.accordion( "option", "active", false );
	equal( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );

	ac.find( ".ui-accordion-header" ).eq( 1 ).click();
	equal( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );
});

test( "{ collapsible: true }", function() {
	var ac = $( "#list1" ).accordion({
		active: 1,
		collapsible: true
	});

	ac.accordion( "option", "active", false );
	equal( ac.accordion( "option", "active" ), false );
	state( ac, 0, 0, 0 );

	ac.accordion( "option", "active", 1 );
	equal( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );

	ac.find( ".ui-accordion-header" ).eq( 1 ).click();
	equals( ac.accordion( "option", "active" ), false );
	state( ac, 0, 0, 0 );
});

// TODO: add event tests

// TODO: add more header tests
test( "{ header: default }", function() {
	// default: > li > :first-child,> :not(li):even
	// > :not(li):even
	state( $( "#list1" ).accordion(), 1, 0, 0);
	// > li > :first-child
	state( $( "#navigation" ).accordion(), 1, 0, 0);
});

test( "{ heightStyle: 'auto' }", function() {
	var ac = $( "#navigation" ).accordion({ heightStyle: "auto" });
	equalHeights( ac, 95, 130 );
});

test( "{ heightStyle: 'content' }", function() {
	var ac = $( "#navigation" ).accordion({ heightStyle: "content" });
	var sizes = ac.find( ".ui-accordion-content" ).map(function() {
		return $( this ).height();
	}).get();
	ok( sizes[ 0 ] >= 70 && sizes[ 0 ] <= 90, "was " + sizes[ 0 ] );
	ok( sizes[ 1 ] >= 98 && sizes[ 1 ] <= 126, "was " + sizes[ 1 ] );
	ok( sizes[ 2 ] >= 42 && sizes[ 2 ] <= 54, "was " + sizes[ 2 ] );
});

test( "{ heightStyle: 'fill' }", function() {
	$( "#navigationWrapper" ).height( 500 );
	var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
	equalHeights( ac, 446, 458 );
});

test( "{ heightStyle: 'fill' } with sibling", function() {
	$( "#navigationWrapper" ).height( 500 );
	$( "
Lorem Ipsum
" )
		.css({
			height: 50,
			marginTop: 20,
			marginBottom: 30
		})
		.prependTo( "#navigationWrapper" );
	var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
	equalHeights( ac , 346, 358);
});

test( "{ heightStyle: 'fill' } with multiple siblings", function() {
	$( "#navigationWrapper" ).height( 500 );
	$( "
Lorem Ipsum
" )
		.css({
			height: 50,
			marginTop: 20,
			marginBottom: 30
		})
		.prependTo( "#navigationWrapper" );
	$( "
Lorem Ipsum
" )
		.css({
			height: 50,
			marginTop: 20,
			marginBottom: 30,
			position: "absolute"
		})
		.prependTo( "#navigationWrapper" );
	$( "
Lorem Ipsum
" )
		.css({
			height: 25,
			marginTop: 10,
			marginBottom: 15
		})
		.prependTo( "#navigationWrapper" );
	var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
	equalHeights( ac, 296, 308 );
});

test( "{ icons: false }", function() {
	var list = $( "#list1" );
	function icons( on ) {
		same( list.find( "span.ui-icon").length, on ? 3 : 0 );
		same( list.hasClass( "ui-accordion-icons" ), on );
	}
	list.accordion();
	icons( true );
	list.accordion( "destroy" ).accordion({
		icons: false
	});
	icons( false );
	list.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
	icons( true );
	list.accordion( "option", "icons", false );
	icons( false );
});

test( "{ icons: hash }", function() {
	var list = $( "#list1" ).accordion({
		icons: { activeHeader: "a1", header: "h1" }
	});
	ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
	list.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
	ok( !list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
	ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
});

}( jQuery ) );
<commit_msg>Accordion: Added tests for custom header option.<commit_after>(function( $ ) {

module( "accordion: options", accordionSetupTeardown() );

test( "{ active: default }", function() {
	var ac = $( "#list1" ).accordion();
	equals( ac.accordion( "option", "active" ), 0 );
	state( ac, 1, 0, 0 );
});

test( "{ active: false }", function() {
	var ac = $( "#list1" ).accordion({
		active: false,
		collapsible: true
	});
	state( ac, 0, 0, 0 );
	equals( ac.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
	equals( ac.accordion( "option", "active" ), false );

	ac.accordion( "option", "collapsible", false );
	state( ac, 1, 0, 0 );
	equals( ac.accordion( "option", "active" ), 0 );

	ac.accordion( "destroy" );
	ac.accordion({
		active: false
	});
	state( ac, 1, 0, 0 );
	strictEqual( ac.accordion( "option", "active" ), 0 );
});

test( "{ active: Number }", function() {
	var ac = $( "#list1" ).accordion({
		active: 2
	});
	equals( ac.accordion( "option", "active" ), 2 );
	state( ac, 0, 0, 1 );

	ac.accordion( "option", "active", 0 );
	equals( ac.accordion( "option", "active" ), 0 );
	state( ac, 1, 0, 0 );

	ac.find( ".ui-accordion-header" ).eq( 1 ).click();
	equals( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );

	ac.accordion( "option", "active", 10 );
	equals( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );
});

if ( $.uiBackCompat === false ) {
	test( "{ active: -Number }", function() {
		var ac = $( "#list1" ).accordion({
			active: -1
		});
		equals( ac.accordion( "option", "active" ), 2 );
		state( ac, 0, 0, 1 );

		ac.accordion( "option", "active", -2 );
		equals( ac.accordion( "option", "active" ), 1 );
		state( ac, 0, 1, 0 );

		ac.accordion( "option", "active", -10 );
		equals( ac.accordion( "option", "active" ), 1 );
		state( ac, 0, 1, 0 );

		ac.accordion( "option", "active", -3 );
		equals( ac.accordion( "option", "active" ), 0 );
		state( ac, 1, 0, 0 );
	});
}

// TODO: add animation tests

test( "{ collapsible: false }", function() {
	var ac = $( "#list1" ).accordion({
		active: 1
	});
	ac.accordion( "option", "active", false );
	equal( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );

	ac.find( ".ui-accordion-header" ).eq( 1 ).click();
	equal( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );
});

test( "{ collapsible: true }", function() {
	var ac = $( "#list1" ).accordion({
		active: 1,
		collapsible: true
	});

	ac.accordion( "option", "active", false );
	equal( ac.accordion( "option", "active" ), false );
	state( ac, 0, 0, 0 );

	ac.accordion( "option", "active", 1 );
	equal( ac.accordion( "option", "active" ), 1 );
	state( ac, 0, 1, 0 );

	ac.find( ".ui-accordion-header" ).eq( 1 ).click();
	equals( ac.accordion( "option", "active" ), false );
	state( ac, 0, 0, 0 );
});

// TODO: add event tests

test( "{ header: default }", function() {
	// default: > li > :first-child,> :not(li):even
	// > :not(li):even
	state( $( "#list1" ).accordion(), 1, 0, 0);
	// > li > :first-child
	state( $( "#navigation" ).accordion(), 1, 0, 0);
});

test( "{ header: custom }", function() {
	var ac = $( "#navigationWrapper" ).accordion({
		header: "h2"
	});
	ac.find( "h2" ).each(function() {
		ok( $( this ).hasClass( "ui-accordion-header" ) );
	});
	equal( ac.find( ".ui-accordion-header" ).length, 3 );
	state( ac, 1, 0, 0 );
	ac.accordion( "option", "active", 2 );
	state( ac, 0, 0, 1 );
});

test( "{ heightStyle: 'auto' }", function() {
	var ac = $( "#navigation" ).accordion({ heightStyle: "auto" });
	equalHeights( ac, 95, 130 );
});

test( "{ heightStyle: 'content' }", function() {
	var ac = $( "#navigation" ).accordion({ heightStyle: "content" });
	var sizes = ac.find( ".ui-accordion-content" ).map(function() {
		return $( this ).height();
	}).get();
	ok( sizes[ 0 ] >= 70 && sizes[ 0 ] <= 90, "was " + sizes[ 0 ] );
	ok( sizes[ 1 ] >= 98 && sizes[ 1 ] <= 126, "was " + sizes[ 1 ] );
	ok( sizes[ 2 ] >= 42 && sizes[ 2 ] <= 54, "was " + sizes[ 2 ] );
});

test( "{ heightStyle: 'fill' }", function() {
	$( "#navigationWrapper" ).height( 500 );
	var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
	equalHeights( ac, 446, 458 );
});

test( "{ heightStyle: 'fill' } with sibling", function() {
	$( "#navigationWrapper" ).height( 500 );
	$( "
Lorem Ipsum
" )
		.css({
			height: 50,
			marginTop: 20,
			marginBottom: 30
		})
		.prependTo( "#navigationWrapper" );
	var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
	equalHeights( ac , 346, 358);
});

test( "{ heightStyle: 'fill' } with multiple siblings", function() {
	$( "#navigationWrapper" ).height( 500 );
	$( "
Lorem Ipsum
" )
		.css({
			height: 50,
			marginTop: 20,
			marginBottom: 30
		})
		.prependTo( "#navigationWrapper" );
	$( "
Lorem Ipsum
" )
		.css({
			height: 50,
			marginTop: 20,
			marginBottom: 30,
			position: "absolute"
		})
		.prependTo( "#navigationWrapper" );
	$( "
Lorem Ipsum
" )
		.css({
			height: 25,
			marginTop: 10,
			marginBottom: 15
		})
		.prependTo( "#navigationWrapper" );
	var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
	equalHeights( ac, 296, 308 );
});

test( "{ icons: false }", function() {
	var list = $( "#list1" );
	function icons( on ) {
		same( list.find( "span.ui-icon").length, on ? 3 : 0 );
		same( list.hasClass( "ui-accordion-icons" ), on );
	}
	list.accordion();
	icons( true );
	list.accordion( "destroy" ).accordion({
		icons: false
	});
	icons( false );
	list.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
	icons( true );
	list.accordion( "option", "icons", false );
	icons( false );
});

test( "{ icons: hash }", function() {
	var list = $( "#list1" ).accordion({
		icons: { activeHeader: "a1", header: "h1" }
	});
	ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
	list.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
	ok( !list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
	ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
});

}( jQuery ) );
<|endoftext|>


<commit_before>import { moduleForComponent, test } from 'ember-qunit';
import TooltipEnabledMixin from 'sl-ember-components/mixins/sl-tooltip-enabled';

moduleForComponent( 'sl-checkbox', 'Unit | Component | sl checkbox', {
    unit: true
});

test( 'Expected Mixins are present', function( assert ) {
    assert.ok(
        TooltipEnabledMixin.detect( this.subject() ),
        'TooltipEnabled Mixin is present'
    );
});

test( 'Default values are correct', function( assert ) {
    const component = this.subject();

    assert.strictEqual(
        component.get( 'checked' ),
        false,
        '"checked" property false by default'
    );

    assert.strictEqual(
        component.get( 'disabled' ),
        false,
        '"disabled" property is text by default'
    );

    assert.strictEqual(
        component.get( 'label' ),
        null,
        '"label" property false by default'
    );

    assert.strictEqual(
        component.get( 'name' ),
        null,
        '"name" property is "name" by default'
    );
});
<commit_msg>fixed grammer inconsistent usage of assert messages<commit_after>import { moduleForComponent, test } from 'ember-qunit';
import TooltipEnabledMixin from 'sl-ember-components/mixins/sl-tooltip-enabled';

moduleForComponent( 'sl-checkbox', 'Unit | Component | sl checkbox', {
    unit: true
});

test( 'Expected Mixins are present', function( assert ) {
    assert.ok(
        TooltipEnabledMixin.detect( this.subject() ),
        'TooltipEnabled Mixin is present'
    );
});

test( 'Default values are correct', function( assert ) {
    const component = this.subject();

    assert.strictEqual(
        component.get( 'checked' ),
        false,
        '"checked" property is false by default'
    );

    assert.strictEqual(
        component.get( 'disabled' ),
        false,
        '"disabled" property is false by default'
    );

    assert.strictEqual(
        component.get( 'label' ),
        null,
        '"label" property is null by default'
    );

    assert.strictEqual(
        component.get( 'name' ),
        null,
        '"name" property is null by default'
    );
});
<|endoftext|>


<commit_before>
//coupled with itemController todo
Todos.TodoController = Ember.ObjectController.extend({
    actions : {
        editTodo : function(){
            this.set('isEditing', true);
        },
        acceptChanges : function(){
            this.set('isEditing', false);

            if(Ember.isEmpty(this.get('model.title')))//if the title was set to the empty string, remove
                this.send('removeTodo');
            else
                this.get('model').save();
        },
        removeTodo : function(){
            var todo = this.get('model');
            todo.deleteRecord();
            todo.save();
        }
    },

    isEditing : false,

    isCompleted : function(_key, _value){
        var model = this.get('model');

        //get (read on init)
        if(_value === undefined)
            return model.get('isCompleted');
        //set
        else
        {
            model.set('isCompleted', _value);
            model.save();
            return _value;
        }
    }.property('model.isCompleted') //makes todo.isCompleted a computed property
});<commit_msg>workaround for using debounce so that enter button triggering both event handlers isn't an issue<commit_after>
//place the function outside of controller so that it can be passed to debounce
//otherwise debounce tries to look up string and doesn't search under actions
//we really want this.send('removeTodo'), but since said statement cannot be placed in the debounce
//this is a workaround
var removeTodo = function(){
    var todo = this.get('model');
    todo.deleteRecord();
    todo.save();
};

//coupled with itemController todo
Todos.TodoController = Ember.ObjectController.extend({
    actions : {
        editTodo : function(){
            this.set('isEditing', true);
        },
        acceptChanges : function(){
            this.set('isEditing', false);

            if(Ember.isEmpty(this.get('model.title')))//if the title was set to the empty string, remove
                Ember.run.debounce(this, removeTodo, 0);    //use debounce for the case in which user presses enter and both event handlers are called
            else
                this.get('model').save();
        },
        removeTodo : removeTodo
    },

    isEditing : false,

    isCompleted : function(_key, _value){
        var model = this.get('model');

        //get (read on init)
        if(_value === undefined)
            return model.get('isCompleted');
        //set
        else
        {
            model.set('isCompleted', _value);
            model.save();
            return _value;
        }
    }.property('model.isCompleted') //makes todo.isCompleted a computed property
});<|endoftext|>


<commit_before>var advBatchStart = 0;
var advBatchSize = 5;
var advResult;

var advanceSearch=function(){
    console.log("advanceSearch");

    $('#advSearchmodal').modal({
        show: 'true'
    });
}

var filterDiv=function(division){
    var out=[];
    var sDivision=biography.divisions[division];
    for (var j=0;j<sDivision.sutras.length;j+=1) {
        var sutra=sDivision.sutras[j];
        out.push(sutra);
    }
    return out;
}

var firstpass=function(field,val){
    var divisions=biography.divisions;

    var out=[];
    for (var i=0;i<divisions.length;i+=1) {
        for (var j=0;j<divisions[i].sutras.length;j+=1) {
            var sutra=divisions[i].sutras[j];
            if (sutra[field].indexOf(val)>-1) {
                out.push(sutra);
            }
        }
    }
    return out;
}

var filterS=function(field,val,previousresult) { //field 欄位名, val 欄位值
    var out=[]
    if (!previousresult) {
        return firstpass(field,val);
    } else {
        for (var i=0;i<previousresult.length;i++) { //other pass
            if (previousresult[i][field].indexOf(val)>-1) {
                out.push(previousresult[i]);
            }
        }
        return out;
    }
}

var filterOr=function(field,val,previousresult) { //field 欄位名, val 欄位值
    var out=[]
    if (!previousresult) {
        return firstpass(field,val);
    } else {
        for (var i=0;i<previousresult.length;i++) { //other pass
            for(var j=0;j<field.length;j+=1){
                if (previousresult[i][field[j]].indexOf(val)>-1) {
                    out.push(previousresult[i]);
                    break;
                }
            }
        }
        return out;
    }
}

var initialRes=function(){
    var divisions=biography.divisions;
    var out=[];
    for (var i=0;i<divisions.length;i+=1) {
        for (var j=0;j<divisions[i].sutras.length;j+=1) {
            var sutra=divisions[i].sutras[j];
            out.push(sutra);
        }
    }
    return out;
}

var creatDivisionDDL=function(){
    var options = "<option value='-1'>-- ALL --</option>";
    var divisions=biography.divisions;
    for (var i=0;i<divisions.length;i+=1) {
        options += "<option value='"+i+"'>"+divisions[i].divisionName+"</option>";
    }
    $("#s_division").html(options);
}

var initialAdvSearch=function(){
    console.log("initialAdvSearch");
    creatDivisionDDL();
}

var showPagination=function(){
    if(advResult.length==0)$("#batches").html("");
    var batch=Math.floor((advResult.length-1)/advBatchSize)+1;
    var html = "";
    if(advBatchStart!=0){
        html += "
«
";
    }
    for(var i=0;i<batch;i+=1){
        var active = "";
        if(i==advBatchStart)active="active";
        html += "
" + (i+1) + "
";
    }
    if(advBatchStart+1<batch){
        html += "
»
";
    }
    $("#advPag").html(html);
}

var goRefPage=function(ref){
    advBatchStart += ref;
    $("#advResult").html( showPage());
    showPagination();
}

var goPage=function(page){
    advBatchStart = page;
    $("#advResult").html( showPage());
    showPagination();
}

var advGoSid=function(Sid){
    gotoSid(Sid);
    $('#advSearchmodal').modal('hide');
}

var showPage=function(){
    var Rtn="";
    var names=wylie.fromWylieWithWildcard($("#names").val());
    /*var tname=$("#tname").val();
    var aname=$("#aname").val();
    var author=$("#author").val();*/

    for(var i=advBatchStart*advBatchSize;i<advResult.length;i+=1){
        if(i==advBatchStart*advBatchSize+advBatchSize)break;
        Rtn+="
"
        + ""+advResult[i].sutraid+""
        +""+advResult[i].tname.replace(names,""+names+"")+""
        +"
";
        /*+",tname:"+advResult[i].tname.replace(names,""+names+"")
        +",aname:"+advResult[i].aname.replace(names,""+names+"")
        +",sname:"+advResult[i].aname.replace(names,""+names+"")
        +",cname:"+advResult[i].aname.replace(names,""+names+"");*/
        //+advResult[i].author.replace(author,""+author+"");
    }
    return Rtn;
}

var doAdvSearch=function(){
    var namesC = ["tname","aname","sname","cname"];
    var singleFilters = ["yana","chakra","location","translator","reviser"];

    var division=$("#s_division").val();
    var names=wylie.fromWylieWithWildcard($("#names").val());

    var res;

    if(division>=0){
        res=filterDiv(division);
    }else{
        res=initialRes();
    }

    if(names){
        res=filterOr(namesC,names,res);
    }
    for(var i=0;i<singleFilters.length;i+=1){
        var column=singleFilters[i];
        if(column){
            res=filterS(column, wylie.fromWylieWithWildcard($("#"+column).val()),res);
        }
    }

    advResult=res;

    advBatchStart = 0;

    var out=showPage();

    showPagination();
    $("#advResult").html( out);
}
<commit_msg>fix issue 24<commit_after>var advBatchStart = 0;
var advBatchSize = 5;
var advResult;

var advanceSearch=function(){
    console.log("advanceSearch");

    $('#advSearchmodal').modal({
        show: 'true'
    });
}

var filterDiv=function(division){
    var out=[];
    var sDivision=biography.divisions[division];
    for (var j=0;j<sDivision.sutras.length;j+=1) {
        var sutra=sDivision.sutras[j];
        out.push(sutra);
    }
    return out;
}

var firstpass=function(field,val){
    var divisions=biography.divisions;

    var out=[];
    for (var i=0;i<divisions.length;i+=1) {
        for (var j=0;j<divisions[i].sutras.length;j+=1) {
            var sutra=divisions[i].sutras[j];
            if (sutra[field].indexOf(val)>-1) {
                out.push(sutra);
            }
        }
    }
    return out;
}

var filterS=function(field,val,previousresult) { //field 欄位名, val 欄位值
    var out=[]
    if (!previousresult) {
        return firstpass(field,val);
    } else {
        for (var i=0;i<previousresult.length;i++) { //other pass
            if (previousresult[i][field].indexOf(val)>-1) {
                out.push(previousresult[i]);
            }
        }
        return out;
    }
}

var filterOr=function(field,val,previousresult) { //field 欄位名, val 欄位值
    var out=[]
    if (!previousresult) {
        return firstpass(field,val);
    } else {
        for (var i=0;i<previousresult.length;i++) { //other pass
            for(var j=0;j<field.length;j+=1){
                if (previousresult[i][field[j]].indexOf(val)>-1) {
                    out.push(previousresult[i]);
                    break;
                }
            }
        }
        return out;
    }
}

var initialRes=function(){
    var divisions=biography.divisions;
    var out=[];
    for (var i=0;i<divisions.length;i+=1) {
        for (var j=0;j<divisions[i].sutras.length;j+=1) {
            var sutra=divisions[i].sutras[j];
            out.push(sutra);
        }
    }
    return out;
}

var creatDivisionDDL=function(){
    var options = "<option value='-1'>-- ALL --</option>";
    var divisions=biography.divisions;
    for (var i=0;i<divisions.length;i+=1) {
        options += "<option value='"+i+"'>"+divisions[i].divisionName+"</option>";
    }
    $("#s_division").html(options);
}

var initialAdvSearch=function(){
    console.log("initialAdvSearch");
    creatDivisionDDL();
}

var showPagination=function(){
    if(advResult.length==0)$("#batches").html("");
    var batch=Math.floor((advResult.length-1)/advBatchSize)+1;
    var html = "";
    if(advBatchStart!=0){
        html += "
«
";
    }
    for(var i=0;i<batch;i+=1){
        var active = "";
        if(i==advBatchStart)active="active";
        html += "
" + (i+1) + "
";
    }
    if(advBatchStart+1<batch){
        html += "
»
";
    }
    $("#advPag").html(html);
}

var goRefPage=function(ref){
    advBatchStart += ref;
    $("#advResult").html( showPage());
    showPagination();
}

var goPage=function(page){
    advBatchStart = page;
    $("#advResult").html( showPage());
    showPagination();
}

var advGoSid=function(Sid){
    gotoSid(Sid);
    $('#advSearchmodal').modal('hide');
}

var showPage=function(){
    var Rtn="";
    var names=wylie.fromWylieWithWildcard($("#names").val());
    /*var tname=$("#tname").val();
    var aname=$("#aname").val();
    var author=$("#author").val();*/

    for(var i=advBatchStart*advBatchSize;i<advResult.length;i+=1){
        if(i==advBatchStart*advBatchSize+advBatchSize)break;
        Rtn+="
"
        + ""+advResult[i].sutraid+""
        +""+advResult[i].tname.replace(names,""+names+"")+""
        +"
";
        /*+",tname:"+advResult[i].tname.replace(names,""+names+"")
        +",aname:"+advResult[i].aname.replace(names,""+names+"")
        +",sname:"+advResult[i].aname.replace(names,""+names+"")
        +",cname:"+advResult[i].aname.replace(names,""+names+"");*/
        //+advResult[i].author.replace(author,""+author+"");
    }
    return Rtn;
}

var doAdvSearch=function(){
    var namesC = ["tname","aname","sname","cname"];
    var singleFilters = ["yana","chakra","location","translator","reviser"];

    var division=$("#s_division").val();
    var names=wylie.fromWylieWithWildcard($("#names").val());

    var res;

    if(division>=0){
        res=filterDiv(division);
    }else{
        res=initialRes();
    }

    if(names){
        res=filterOr(namesC,names,res);
    }
    for(var i=0;i<singleFilters.length;i+=1){
        var column=singleFilters[i];
        if(column){
            res=filterS(column, wylie.fromWylieWithWildcard($("#"+column).val()),res);
        }
    }

    advResult=res;

    advBatchStart = 0;

    var out=showPage();

    showPagination();
    $("#advResult").html( out);
}
<|endoftext|>


<commit_before>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

// Utils
import { getDatasetDefaultEditableWidget } from 'layout/explore-detail/explore-detail-helpers';
import { breakpoints } from 'utils/responsive';

// Components
import MediaQuery from 'react-responsive';

// Widget editor
import WidgetEditor, { VegaChart } from 'widget-editor';

// Modal
import Modal from 'components/modal/modal-component';
import SaveWidgetModal from 'components/modal/SaveWidgetModal';

// Constants
class ExploreDetailWidgetEditor extends PureComponent {
  static propTypes = {
    dataset: PropTypes.object,
    responsive: PropTypes.object
  }

  state = {
    showSaveModal: false
  }

  handleToggleSaveWidget = (bool) => {
    this.setState({ showSaveModal: bool });
  }

  render() {
    const { dataset, responsive } = this.props;
    const defaultEditableWidget = getDatasetDefaultEditableWidget(dataset);

    return (

        <MediaQuery
          minDeviceWidth={breakpoints.large}
          values={{ deviceWidth: responsive.fakeWidth }}
        >
          <WidgetEditor
            datasetId={dataset.id}
            widgetId={defaultEditableWidget && defaultEditableWidget.id}
            saveButtonMode="auto"
            embedButtonMode="auto"
            titleMode="auto"
            provideWidgetConfig={(func) => { this.onGetWidgetConfig = func; }}
            onSave={() => this.handleToggleSaveWidget(true)}
          />

          <Modal
            isOpen={this.state.showSaveModal}
            className="-medium"
            onRequestClose={() => this.handleToggleSaveWidget(false)}
          >
            <SaveWidgetModal
              dataset={dataset.id}
              getWidgetConfig={this.onGetWidgetConfig}
              onRequestClose={() => this.handleToggleSaveWidget(false)}
            />
          </Modal>
        </MediaQuery>

        {defaultEditableWidget &&
          <MediaQuery
            maxDeviceWidth={breakpoints.large - 1}
            values={{ deviceWidth: responsive.fakeWidth }}
          >
            <VegaChart
              data={defaultEditableWidget.widgetConfig}
              reloadOnResize
            />
          </MediaQuery>
        }

    );
  }
}

export default ExploreDetailWidgetEditor;
<commit_msg>Explore detail: mobile vega chart<commit_after>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

// Utils
import { getDatasetDefaultEditableWidget } from 'layout/explore-detail/explore-detail-helpers';
import { breakpoints } from 'utils/responsive';

// Components
import MediaQuery from 'react-responsive';

// Widget editor
import WidgetEditor, { VegaChart, getVegaTheme } from 'widget-editor';

// Modal
import Modal from 'components/modal/modal-component';
import SaveWidgetModal from 'components/modal/SaveWidgetModal';

// Constants
class ExploreDetailWidgetEditor extends PureComponent {
  static propTypes = {
    dataset: PropTypes.object,
    responsive: PropTypes.object
  }

  state = {
    showSaveModal: false
  }

  handleToggleSaveWidget = (bool) => {
    this.setState({ showSaveModal: bool });
  }

  render() {
    const { dataset, responsive } = this.props;
    const defaultEditableWidget = getDatasetDefaultEditableWidget(dataset);

    return (

        <MediaQuery
          minDeviceWidth={breakpoints.large}
          values={{ deviceWidth: responsive.fakeWidth }}
        >
          <WidgetEditor
            datasetId={dataset.id}
            widgetId={defaultEditableWidget && defaultEditableWidget.id}
            saveButtonMode="auto"
            embedButtonMode="auto"
            titleMode="auto"
            provideWidgetConfig={(func) => { this.onGetWidgetConfig = func; }}
            onSave={() => this.handleToggleSaveWidget(true)}
          />

          <Modal
            isOpen={this.state.showSaveModal}
            className="-medium"
            onRequestClose={() => this.handleToggleSaveWidget(false)}
          >
            <SaveWidgetModal
              dataset={dataset.id}
              getWidgetConfig={this.onGetWidgetConfig}
              onRequestClose={() => this.handleToggleSaveWidget(false)}
            />
          </Modal>
        </MediaQuery>

        {defaultEditableWidget &&
          <MediaQuery
            maxDeviceWidth={breakpoints.large - 1}
            values={{ deviceWidth: responsive.fakeWidth }}
          >

                  <VegaChart
                    data={defaultEditableWidget.widgetConfig}
                    theme={getVegaTheme()}
                    reloadOnResize
                  />

          </MediaQuery>
        }

    );
  }
}

export default ExploreDetailWidgetEditor;
<|endoftext|>


<commit_before>DGBlock = function(arrayBuffer, blockOffset, littleEndian){
  this.blockTypeIdentifier = null;
  this.blockSize = null;
  this.pNextDGBlock = null;
  this.pFirstCGBlock = null;
  this.pTRBlock = null;
  this.pDataBlock = null;
  this.numberOfChannelGroups = null;
  this.numberOfRecordIDs = null;

  this.pThisBlock = blockOffset;
  this.trBlock = null;
  this.cgBlocks = [];

  this.initiallize(arrayBuffer, blockOffset, littleEndian);
};

DGBlock.prototype.initiallize = function(arrayBuffer, blockOffset, littleEndian){
  var offset = blockOffset;
  var len;

  len = 2;
  this.blockTypeIdentifier = MDF.ab2str(arrayBuffer, offset, len);
  offset += len;

  len = 2;
  this.blockSize = MDF.ab2uint16(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pNextDGBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pFirstCGBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pTRBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pDataBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 2;
  this.numberOfChannelGroups = MDF.ab2uint16(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 2;
  this.numberOfRecordIDs = MDF.ab2uint16(arrayBuffer, offset, littleEndian);
  offset += len;

  this.setCGBlocks(arrayBuffer, this.pFirstCGBlock, littleEndian);
  this.setTRBlock(arrayBuffer, this.pTRBlock, littleEndian);
};

DGBlock.prototype.setCGBlocks = function(arrayBuffer, initialOffset, littleEndian){
  var offset = initialOffset;

  while(offset){
    var cgBlock = new CGBlock(arrayBuffer, offset, littleEndian);
    this.cgBlocks.push(cgBlock);
    offset = cgBlock.pNextCGBlock;
  }
};

DGBlock.prototype.setTRBlock = function(arrayBuffer, initialOffset, littleEndian){
  if(initialOffset){
    this.trBlock = new TRBlock(arrayBuffer, initialOffset, littleEndian);
  }
};

DGBlock.prototype.isSorted = function(){
  return (this.cgBlocks.length == 1);
};

DGBlock.prototype.readDataBlock = function(arrayBuffer, initialOffset, littleEndian){
  var offset = initialOffset;

  var cgCounters = (new Array(this.cgBlocks.length)).fill(0); // Zeros(this.cgBlocks.length);

  while(true){
    var cgIndex = 0;
    if(this.isSorted() == false){
      var currentRecordID = MDF.ab2uint8(arrayBuffer, offset);
      for(var i = 0; i < this.cgBlocks.length; i++){
        if(this.cgBlocks[i].recordID == currentRecordID){
          cgIndex = i;
          break;
        }
      }
    }
    var currentCGBlock = this.cgBlocks[cgIndex];

    if(this.numberOfRecordIDs > 0)  offset += 1;

    for(var i = 0; i < currentCGBlock.cnBlocks.length; i++){
      var theCNBlock = currentCGBlock.cnBlocks[i];
      theCNBlock.pushRawData(arrayBuffer, offset, littleEndian);
    }

    offset += currentCGBlock.sizeOfDataRecord;
    if(this.numberOfRecordIDs == 2)  offset += 1;

    cgCounters[cgIndex]++;

    var isEndOfDataBlock = true;
    for(var i = 0; i < this.cgBlocks.length; i++){
      if(cgCounters[i] != this.cgBlocks[i].numberOfRecords){
        isEndOfDataBlock = false;
        break;
      }
    }
    if(isEndOfDataBlock) break;
  }
};
<commit_msg>bug fix<commit_after>DGBlock = function(arrayBuffer, blockOffset, littleEndian){
  this.blockTypeIdentifier = null;
  this.blockSize = null;
  this.pNextDGBlock = null;
  this.pFirstCGBlock = null;
  this.pTRBlock = null;
  this.pDataBlock = null;
  this.numberOfChannelGroups = null;
  this.numberOfRecordIDs = null;

  this.pThisBlock = blockOffset;
  this.trBlock = null;
  this.cgBlocks = [];

  this.initiallize(arrayBuffer, blockOffset, littleEndian);
};

DGBlock.prototype.initiallize = function(arrayBuffer, blockOffset, littleEndian){
  var offset = blockOffset;
  var len;

  len = 2;
  this.blockTypeIdentifier = MDF.ab2str(arrayBuffer, offset, len);
  offset += len;

  len = 2;
  this.blockSize = MDF.ab2uint16(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pNextDGBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pFirstCGBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pTRBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 4;
  this.pDataBlock = MDF.ab2uint32(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 2;
  this.numberOfChannelGroups = MDF.ab2uint16(arrayBuffer, offset, littleEndian);
  offset += len;

  len = 2;
  this.numberOfRecordIDs = MDF.ab2uint16(arrayBuffer, offset, littleEndian);
  offset += len;

  this.setCGBlocks(arrayBuffer, this.pFirstCGBlock, littleEndian);
  this.setTRBlock(arrayBuffer, this.pTRBlock, littleEndian);
};

DGBlock.prototype.setCGBlocks = function(arrayBuffer, initialOffset, littleEndian){
  var offset = initialOffset;

  while(offset){
    var cgBlock = new CGBlock(arrayBuffer, offset, littleEndian);
    this.cgBlocks.push(cgBlock);
    offset = cgBlock.pNextCGBlock;
  }
};

DGBlock.prototype.setTRBlock = function(arrayBuffer, initialOffset, littleEndian){
  if(initialOffset){
    this.trBlock = new TRBlock(arrayBuffer, initialOffset, littleEndian);
  }
};

DGBlock.prototype.isSorted = function(){
  return (this.cgBlocks.length == 1);
};

DGBlock.prototype.readDataBlock = function(arrayBuffer, initialOffset, littleEndian){
  var offset = initialOffset;

  if(offset){
    var cgCounters = (new Array(this.cgBlocks.length)).fill(0); // Zeros(this.cgBlocks.length);

    while(true){
      var cgIndex = 0;
      if(this.isSorted() == false){
        var currentRecordID = MDF.ab2uint8(arrayBuffer, offset);
        for(var i = 0; i < this.cgBlocks.length; i++){
          if(this.cgBlocks[i].recordID == currentRecordID){
            cgIndex = i;
            break;
          }
        }
      }
      var currentCGBlock = this.cgBlocks[cgIndex];

      if(this.numberOfRecordIDs > 0)  offset += 1;

      for(var i = 0; i < currentCGBlock.cnBlocks.length; i++){
        var theCNBlock = currentCGBlock.cnBlocks[i];
        theCNBlock.pushRawData(arrayBuffer, offset, littleEndian);
      }

      offset += currentCGBlock.sizeOfDataRecord;
      if(this.numberOfRecordIDs == 2)  offset += 1;

      cgCounters[cgIndex]++;

      var isEndOfDataBlock = true;
      for(var i = 0; i < this.cgBlocks.length; i++){
        if(cgCounters[i] != this.cgBlocks[i].numberOfRecords){
          isEndOfDataBlock = false;
          break;
        }
      }
      if(isEndOfDataBlock) break;
    }
  }
};
<|endoftext|>


<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

const gulp = require('gulp');
const replace = require('gulp-replace');
const rename = require('gulp-rename');
const shell = require('gulp-shell');
const es = require('event-stream');
const vfs = require('vinyl-fs');
const util = require('./lib/util');
const packageJson = require('../package.json');
const product = require('../product.json');
const rpmDependencies = require('../resources/linux/rpm/dependencies');

const linuxPackageRevision = Math.floor(new Date().getTime() / 1000);

const flatpakManifest = {
	appId: product.darwinBundleIdentifier,  // We need a reverse-url style identifier.
	sdk: 'org.freedesktop.Sdk',
	runtime: 'org.freedesktop.Sdk',
	runtimeVersion: '1.4',
	base: 'io.atom.electron.BaseApp',
	baseFlatpakref: 'https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/electron-base-app-master.flatpakref',
	command: product.applicationName,
	symlinks: [
		['/share/' + product.applicationName + '/bin/' + product.applicationName, '/bin/' + product.applicationName],
	],
	finishArgs: [
		'--share=ipc', '--socket=x11',  // Allow showing X11 windows.
		'--share=network',              // Network access (e.g. for installing extension).
		'--filesystem=host',            // Allow access to the whole file system.
		'--device=dri',                 // Allow OpenGL rendering.
		'--filesystem=/tmp',            // Needed for Chromium's single instance check.
		'--socket=pulseaudio',          // Some extensions may want to play sounds...
		'--talk-name=org.freedesktop.Notifications',  // ...or pop up notifications.
	],
};

function getDebPackageArch(arch) {
	return { x64: 'amd64', ia32: 'i386', arm: 'armhf' }[arch];
}

function prepareDebPackage(arch) {
	const binaryDir = '../VSCode-linux-' + arch;
	const debArch = getDebPackageArch(arch);
	const destination = '.build/linux/deb/' + debArch + '/' + product.applicationName + '-' + debArch;

	return function () {
		const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@NAME_SHORT@@', product.nameShort))
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('usr/share/applications/' + product.applicationName + '.desktop'));

		const icon = gulp.src('resources/linux/code.png', { base: '.' })
			.pipe(rename('usr/share/pixmaps/' + product.applicationName + '.png'));

		const code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
			.pipe(rename(function (p) { p.dirname = 'usr/share/' + product.applicationName + '/' + p.dirname; }));

		let size = 0;
		const control = code.pipe(es.through(
			function (f) { size += f.isDirectory() ? 4096 : f.contents.length; },
			function () {
				const that = this;
				gulp.src('resources/linux/debian/control.template', { base: '.' })
					.pipe(replace('@@NAME@@', product.applicationName))
					.pipe(replace('@@VERSION@@', packageJson.version + '-' + linuxPackageRevision))
					.pipe(replace('@@ARCHITECTURE@@', debArch))
					.pipe(replace('@@INSTALLEDSIZE@@', Math.ceil(size / 1024)))
					.pipe(rename('DEBIAN/control'))
					.pipe(es.through(function (f) { that.emit('data', f); }, function () { that.emit('end'); }));
			}));

		const prerm = gulp.src('resources/linux/debian/prerm.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('DEBIAN/prerm'));

		const postrm = gulp.src('resources/linux/debian/postrm.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('DEBIAN/postrm'));

		const postinst = gulp.src('resources/linux/debian/postinst.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(replace('@@ARCHITECTURE@@', debArch))
			.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
			.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
			.pipe(rename('DEBIAN/postinst'));

		const all = es.merge(control, postinst, postrm, prerm, desktop, icon, code);

		return all.pipe(vfs.dest(destination));
	};
}

function buildDebPackage(arch) {
	const debArch = getDebPackageArch(arch);
	return shell.task([
		'chmod 755 ' + product.applicationName + '-' + debArch + '/DEBIAN/postinst ' + product.applicationName + '-' + debArch + '/DEBIAN/prerm ' + product.applicationName + '-' + debArch + '/DEBIAN/postrm',
		'mkdir -p deb',
		'fakeroot dpkg-deb -b ' + product.applicationName + '-' + debArch + ' deb',
		'dpkg-scanpackages deb /dev/null > Packages'
	], { cwd: '.build/linux/deb/' + debArch});
}

function getRpmBuildPath(rpmArch) {
	return '.build/linux/rpm/' + rpmArch + '/rpmbuild';
}

function getRpmPackageArch(arch) {
	return { x64: 'x86_64', ia32: 'i386', arm: 'armhf' }[arch];
}

function prepareRpmPackage(arch) {
	const binaryDir = '../VSCode-linux-' + arch;
	const rpmArch = getRpmPackageArch(arch);

	return function () {
		const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@NAME_SHORT@@', product.nameShort))
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('BUILD/usr/share/applications/' + product.applicationName + '.desktop'));

		const icon = gulp.src('resources/linux/code.png', { base: '.' })
			.pipe(rename('BUILD/usr/share/pixmaps/' + product.applicationName + '.png'));

		const code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
			.pipe(rename(function (p) { p.dirname = 'BUILD/usr/share/' + product.applicationName + '/' + p.dirname; }));

		const spec = gulp.src('resources/linux/rpm/code.spec.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@VERSION@@', packageJson.version))
			.pipe(replace('@@RELEASE@@', linuxPackageRevision))
			.pipe(replace('@@ARCHITECTURE@@', rpmArch))
			.pipe(replace('@@LICENSE@@', product.licenseName))
			.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
			.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
			.pipe(replace('@@DEPENDENCIES@@', rpmDependencies[rpmArch].join(', ')))
			.pipe(rename('SPECS/' + product.applicationName + '.spec'));

		const specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' })
			.pipe(rename('SOURCES/' + product.applicationName + '.xpm'));

		const all = es.merge(code, desktop, icon, spec, specIcon);

		return all.pipe(vfs.dest(getRpmBuildPath(rpmArch)));
	};
}

function buildRpmPackage(arch) {
	const rpmArch = getRpmPackageArch(arch);
	const rpmBuildPath = getRpmBuildPath(rpmArch);
	const rpmOut = rpmBuildPath + '/RPMS/' + rpmArch;
	const destination = '.build/linux/rpm/' + rpmArch;

	return shell.task([
		'mkdir -p ' + destination,
		'HOME="$(pwd)/' + destination + '" fakeroot rpmbuild -bb ' + rpmBuildPath + '/SPECS/' + product.applicationName + '.spec --target=' + rpmArch,
		'cp "' + rpmOut + '/$(ls ' + rpmOut + ')" ' + destination + '/',
		'createrepo ' + destination
	]);
}

function getFlatpakArch(arch) {
	return { x64: 'x86_64', ia32: 'i386', arm: 'arm' }[arch];
}

function prepareFlatpak(arch) {
	// This is not imported in the global scope to avoid requiring ImageMagick
	// (or GraphicsMagick) when not building building Flatpak bundles.
	const imgResize = require('gulp-image-resize');

	const binaryDir = '../VSCode-linux-' + arch;
	const flatpakArch = getFlatpakArch(arch);
	const destination = '.build/linux/flatpak/' + flatpakArch;

	return function () {
		const all = [16, 24, 32, 48, 64, 128, 192, 256, 512].map(function (size) {
			return gulp.src('resources/linux/code.png', { base: '.' })
				.pipe(imgResize({ width: size, height: size, format: "png", noProfile: true }))
				.pipe(rename('share/icons/hicolor/' + size + 'x' + size + '/apps/' + flatpakManifest.appId + '.png'));
		});

		all.push(gulp.src('resources/linux/code.desktop', { base: '.' })
			.pipe(replace('Exec=/usr/share/@@NAME@@/@@NAME@@', 'Exec=' + product.applicationName))
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@NAME_SHORT@@', product.nameShort))
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('share/applications/' + flatpakManifest.appId + '.desktop')));

		all.push(gulp.src(binaryDir + '/**/*', { base:binaryDir })
			.pipe(rename(function (p) {
				p.dirname = 'share/' + product.applicationName + '/' + p.dirname;
			})));

		return es.merge(all).pipe(vfs.dest(destination));
	}
}

function buildFlatpak(arch) {
	const flatpakArch = getFlatpakArch(arch);
	const manifest = {};
	for (var k in flatpakManifest) {
		manifest[k] = flatpakManifest[k];
	}
	manifest.files = [
		['.build/linux/flatpak/' + flatpakArch, '/'],
	];
	const buildOptions = {
		arch: flatpakArch,
		bundlePath: manifest.appId + '-' + flatpakArch + '.flatpak',
	};
	return function (cb) {
		require('flatpak-bundler').bundle(manifest, buildOptions, cb);
	}
}

gulp.task('clean-vscode-linux-ia32-deb', util.rimraf('.build/linux/deb/i386'));
gulp.task('clean-vscode-linux-x64-deb', util.rimraf('.build/linux/deb/amd64'));
gulp.task('clean-vscode-linux-arm-deb', util.rimraf('.build/linux/deb/armhf'));
gulp.task('clean-vscode-linux-ia32-rpm', util.rimraf('.build/linux/rpm/i386'));
gulp.task('clean-vscode-linux-x64-rpm', util.rimraf('.build/linux/rpm/x86_64'));
gulp.task('clean-vscode-linux-arm-rpm', util.rimraf('.build/linux/rpm/armhf'));

gulp.task('vscode-linux-ia32-prepare-deb', ['clean-vscode-linux-ia32-deb', 'vscode-linux-ia32-min'], prepareDebPackage('ia32'));
gulp.task('vscode-linux-x64-prepare-deb', ['clean-vscode-linux-x64-deb', 'vscode-linux-x64-min'], prepareDebPackage('x64'));
gulp.task('vscode-linux-arm-prepare-deb', ['clean-vscode-linux-arm-deb', 'vscode-linux-arm-min'], prepareDebPackage('arm'));
gulp.task('vscode-linux-ia32-build-deb', ['vscode-linux-ia32-prepare-deb'], buildDebPackage('ia32'));
gulp.task('vscode-linux-x64-build-deb', ['vscode-linux-x64-prepare-deb'], buildDebPackage('x64'));
gulp.task('vscode-linux-arm-build-deb', ['vscode-linux-arm-prepare-deb'], buildDebPackage('arm'));

gulp.task('vscode-linux-ia32-prepare-rpm', ['clean-vscode-linux-ia32-rpm', 'vscode-linux-ia32-min'], prepareRpmPackage('ia32'));
gulp.task('vscode-linux-x64-prepare-rpm', ['clean-vscode-linux-x64-rpm', 'vscode-linux-x64-min'], prepareRpmPackage('x64'));
gulp.task('vscode-linux-arm-prepare-rpm', ['clean-vscode-linux-arm-rpm', 'vscode-linux-arm-min'], prepareRpmPackage('arm'));
gulp.task('vscode-linux-ia32-build-rpm', ['vscode-linux-ia32-prepare-rpm'], buildRpmPackage('ia32'));
gulp.task('vscode-linux-x64-build-rpm', ['vscode-linux-x64-prepare-rpm'], buildRpmPackage('x64'));
gulp.task('vscode-linux-arm-build-rpm', ['vscode-linux-arm-prepare-rpm'], buildRpmPackage('arm'));

gulp.task('clean-vscode-linux-ia32-flatpak', util.rimraf('.build/linux/flatpak/i386'));
gulp.task('clean-vscode-linux-x64-flatpak', util.rimraf('.build/linux/flatpak/x86_64'));
gulp.task('clean-vscode-linux-arm-flatpak', util.rimraf('.build/linux/flatpak/arm'));

gulp.task('vscode-linux-ia32-prepare-flatpak', ['clean-vscode-linux-ia32-flatpak', 'vscode-linux-ia32-min'], prepareFlatpak('ia32'));
gulp.task('vscode-linux-x64-prepare-flatpak', ['clean-vscode-linux-x64-flatpak', 'vscode-linux-x64-min'], prepareFlatpak('x64'));
gulp.task('vscode-linux-arm-prepare-flatpak', ['clean-vscode-linux-arm-flatpak', 'vscode-linux-arm-min'], prepareFlatpak('arm'));

gulp.task('vscode-linux-ia32-flatpak', ['vscode-linux-ia32-prepare-flatpak'], buildFlatpak('ia32'));
gulp.task('vscode-linux-x64-flatpak', ['vscode-linux-x64-prepare-flatpak'], buildFlatpak('x64'));
gulp.task('vscode-linux-arm-flatpak', ['vscode-linux-arm-prepare-flatpak'], buildFlatpak('arm'));
<commit_msg>Remove gulp-image-resize dep unless we build flatpak<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

const gulp = require('gulp');
const replace = require('gulp-replace');
const rename = require('gulp-rename');
const shell = require('gulp-shell');
const es = require('event-stream');
const vfs = require('vinyl-fs');
const util = require('./lib/util');
const packageJson = require('../package.json');
const product = require('../product.json');
const rpmDependencies = require('../resources/linux/rpm/dependencies');

const linuxPackageRevision = Math.floor(new Date().getTime() / 1000);

const flatpakManifest = {
	appId: product.darwinBundleIdentifier,  // We need a reverse-url style identifier.
	sdk: 'org.freedesktop.Sdk',
	runtime: 'org.freedesktop.Sdk',
	runtimeVersion: '1.4',
	base: 'io.atom.electron.BaseApp',
	baseFlatpakref: 'https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/electron-base-app-master.flatpakref',
	command: product.applicationName,
	symlinks: [
		['/share/' + product.applicationName + '/bin/' + product.applicationName, '/bin/' + product.applicationName],
	],
	finishArgs: [
		'--share=ipc', '--socket=x11',  // Allow showing X11 windows.
		'--share=network',              // Network access (e.g. for installing extension).
		'--filesystem=host',            // Allow access to the whole file system.
		'--device=dri',                 // Allow OpenGL rendering.
		'--filesystem=/tmp',            // Needed for Chromium's single instance check.
		'--socket=pulseaudio',          // Some extensions may want to play sounds...
		'--talk-name=org.freedesktop.Notifications',  // ...or pop up notifications.
	],
};

function getDebPackageArch(arch) {
	return { x64: 'amd64', ia32: 'i386', arm: 'armhf' }[arch];
}

function prepareDebPackage(arch) {
	const binaryDir = '../VSCode-linux-' + arch;
	const debArch = getDebPackageArch(arch);
	const destination = '.build/linux/deb/' + debArch + '/' + product.applicationName + '-' + debArch;

	return function () {
		const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@NAME_SHORT@@', product.nameShort))
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('usr/share/applications/' + product.applicationName + '.desktop'));

		const icon = gulp.src('resources/linux/code.png', { base: '.' })
			.pipe(rename('usr/share/pixmaps/' + product.applicationName + '.png'));

		const code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
			.pipe(rename(function (p) { p.dirname = 'usr/share/' + product.applicationName + '/' + p.dirname; }));

		let size = 0;
		const control = code.pipe(es.through(
			function (f) { size += f.isDirectory() ? 4096 : f.contents.length; },
			function () {
				const that = this;
				gulp.src('resources/linux/debian/control.template', { base: '.' })
					.pipe(replace('@@NAME@@', product.applicationName))
					.pipe(replace('@@VERSION@@', packageJson.version + '-' + linuxPackageRevision))
					.pipe(replace('@@ARCHITECTURE@@', debArch))
					.pipe(replace('@@INSTALLEDSIZE@@', Math.ceil(size / 1024)))
					.pipe(rename('DEBIAN/control'))
					.pipe(es.through(function (f) { that.emit('data', f); }, function () { that.emit('end'); }));
			}));

		const prerm = gulp.src('resources/linux/debian/prerm.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('DEBIAN/prerm'));

		const postrm = gulp.src('resources/linux/debian/postrm.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('DEBIAN/postrm'));

		const postinst = gulp.src('resources/linux/debian/postinst.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(replace('@@ARCHITECTURE@@', debArch))
			.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
			.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
			.pipe(rename('DEBIAN/postinst'));

		const all = es.merge(control, postinst, postrm, prerm, desktop, icon, code);

		return all.pipe(vfs.dest(destination));
	};
}

function buildDebPackage(arch) {
	const debArch = getDebPackageArch(arch);
	return shell.task([
		'chmod 755 ' + product.applicationName + '-' + debArch + '/DEBIAN/postinst ' + product.applicationName + '-' + debArch + '/DEBIAN/prerm ' + product.applicationName + '-' + debArch + '/DEBIAN/postrm',
		'mkdir -p deb',
		'fakeroot dpkg-deb -b ' + product.applicationName + '-' + debArch + ' deb',
		'dpkg-scanpackages deb /dev/null > Packages'
	], { cwd: '.build/linux/deb/' + debArch});
}

function getRpmBuildPath(rpmArch) {
	return '.build/linux/rpm/' + rpmArch + '/rpmbuild';
}

function getRpmPackageArch(arch) {
	return { x64: 'x86_64', ia32: 'i386', arm: 'armhf' }[arch];
}

function prepareRpmPackage(arch) {
	const binaryDir = '../VSCode-linux-' + arch;
	const rpmArch = getRpmPackageArch(arch);

	return function () {
		const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@NAME_SHORT@@', product.nameShort))
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('BUILD/usr/share/applications/' + product.applicationName + '.desktop'));

		const icon = gulp.src('resources/linux/code.png', { base: '.' })
			.pipe(rename('BUILD/usr/share/pixmaps/' + product.applicationName + '.png'));

		const code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
			.pipe(rename(function (p) { p.dirname = 'BUILD/usr/share/' + product.applicationName + '/' + p.dirname; }));

		const spec = gulp.src('resources/linux/rpm/code.spec.template', { base: '.' })
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@VERSION@@', packageJson.version))
			.pipe(replace('@@RELEASE@@', linuxPackageRevision))
			.pipe(replace('@@ARCHITECTURE@@', rpmArch))
			.pipe(replace('@@LICENSE@@', product.licenseName))
			.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
			.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
			.pipe(replace('@@DEPENDENCIES@@', rpmDependencies[rpmArch].join(', ')))
			.pipe(rename('SPECS/' + product.applicationName + '.spec'));

		const specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' })
			.pipe(rename('SOURCES/' + product.applicationName + '.xpm'));

		const all = es.merge(code, desktop, icon, spec, specIcon);

		return all.pipe(vfs.dest(getRpmBuildPath(rpmArch)));
	};
}

function buildRpmPackage(arch) {
	const rpmArch = getRpmPackageArch(arch);
	const rpmBuildPath = getRpmBuildPath(rpmArch);
	const rpmOut = rpmBuildPath + '/RPMS/' + rpmArch;
	const destination = '.build/linux/rpm/' + rpmArch;

	return shell.task([
		'mkdir -p ' + destination,
		'HOME="$(pwd)/' + destination + '" fakeroot rpmbuild -bb ' + rpmBuildPath + '/SPECS/' + product.applicationName + '.spec --target=' + rpmArch,
		'cp "' + rpmOut + '/$(ls ' + rpmOut + ')" ' + destination + '/',
		'createrepo ' + destination
	]);
}

function getFlatpakArch(arch) {
	return { x64: 'x86_64', ia32: 'i386', arm: 'arm' }[arch];
}

function prepareFlatpak(arch) {
	const binaryDir = '../VSCode-linux-' + arch;
	const flatpakArch = getFlatpakArch(arch);
	const destination = '.build/linux/flatpak/' + flatpakArch;

	return function () {
		// This is not imported in the global scope to avoid requiring ImageMagick
		// (or GraphicsMagick) when not building building Flatpak bundles.
		const imgResize = require('gulp-image-resize');

		const all = [16, 24, 32, 48, 64, 128, 192, 256, 512].map(function (size) {
			return gulp.src('resources/linux/code.png', { base: '.' })
				.pipe(imgResize({ width: size, height: size, format: "png", noProfile: true }))
				.pipe(rename('share/icons/hicolor/' + size + 'x' + size + '/apps/' + flatpakManifest.appId + '.png'));
		});

		all.push(gulp.src('resources/linux/code.desktop', { base: '.' })
			.pipe(replace('Exec=/usr/share/@@NAME@@/@@NAME@@', 'Exec=' + product.applicationName))
			.pipe(replace('@@NAME_LONG@@', product.nameLong))
			.pipe(replace('@@NAME_SHORT@@', product.nameShort))
			.pipe(replace('@@NAME@@', product.applicationName))
			.pipe(rename('share/applications/' + flatpakManifest.appId + '.desktop')));

		all.push(gulp.src(binaryDir + '/**/*', { base:binaryDir })
			.pipe(rename(function (p) {
				p.dirname = 'share/' + product.applicationName + '/' + p.dirname;
			})));

		return es.merge(all).pipe(vfs.dest(destination));
	}
}

function buildFlatpak(arch) {
	const flatpakArch = getFlatpakArch(arch);
	const manifest = {};
	for (var k in flatpakManifest) {
		manifest[k] = flatpakManifest[k];
	}
	manifest.files = [
		['.build/linux/flatpak/' + flatpakArch, '/'],
	];
	const buildOptions = {
		arch: flatpakArch,
		bundlePath: manifest.appId + '-' + flatpakArch + '.flatpak',
	};
	return function (cb) {
		require('flatpak-bundler').bundle(manifest, buildOptions, cb);
	}
}

gulp.task('clean-vscode-linux-ia32-deb', util.rimraf('.build/linux/deb/i386'));
gulp.task('clean-vscode-linux-x64-deb', util.rimraf('.build/linux/deb/amd64'));
gulp.task('clean-vscode-linux-arm-deb', util.rimraf('.build/linux/deb/armhf'));
gulp.task('clean-vscode-linux-ia32-rpm', util.rimraf('.build/linux/rpm/i386'));
gulp.task('clean-vscode-linux-x64-rpm', util.rimraf('.build/linux/rpm/x86_64'));
gulp.task('clean-vscode-linux-arm-rpm', util.rimraf('.build/linux/rpm/armhf'));

gulp.task('vscode-linux-ia32-prepare-deb', ['clean-vscode-linux-ia32-deb', 'vscode-linux-ia32-min'], prepareDebPackage('ia32'));
gulp.task('vscode-linux-x64-prepare-deb', ['clean-vscode-linux-x64-deb', 'vscode-linux-x64-min'], prepareDebPackage('x64'));
gulp.task('vscode-linux-arm-prepare-deb', ['clean-vscode-linux-arm-deb', 'vscode-linux-arm-min'], prepareDebPackage('arm'));
gulp.task('vscode-linux-ia32-build-deb', ['vscode-linux-ia32-prepare-deb'], buildDebPackage('ia32'));
gulp.task('vscode-linux-x64-build-deb', ['vscode-linux-x64-prepare-deb'], buildDebPackage('x64'));
gulp.task('vscode-linux-arm-build-deb', ['vscode-linux-arm-prepare-deb'], buildDebPackage('arm'));

gulp.task('vscode-linux-ia32-prepare-rpm', ['clean-vscode-linux-ia32-rpm', 'vscode-linux-ia32-min'], prepareRpmPackage('ia32'));
gulp.task('vscode-linux-x64-prepare-rpm', ['clean-vscode-linux-x64-rpm', 'vscode-linux-x64-min'], prepareRpmPackage('x64'));
gulp.task('vscode-linux-arm-prepare-rpm', ['clean-vscode-linux-arm-rpm', 'vscode-linux-arm-min'], prepareRpmPackage('arm'));
gulp.task('vscode-linux-ia32-build-rpm', ['vscode-linux-ia32-prepare-rpm'], buildRpmPackage('ia32'));
gulp.task('vscode-linux-x64-build-rpm', ['vscode-linux-x64-prepare-rpm'], buildRpmPackage('x64'));
gulp.task('vscode-linux-arm-build-rpm', ['vscode-linux-arm-prepare-rpm'], buildRpmPackage('arm'));

gulp.task('clean-vscode-linux-ia32-flatpak', util.rimraf('.build/linux/flatpak/i386'));
gulp.task('clean-vscode-linux-x64-flatpak', util.rimraf('.build/linux/flatpak/x86_64'));
gulp.task('clean-vscode-linux-arm-flatpak', util.rimraf('.build/linux/flatpak/arm'));

gulp.task('vscode-linux-ia32-prepare-flatpak', ['clean-vscode-linux-ia32-flatpak', 'vscode-linux-ia32-min'], prepareFlatpak('ia32'));
gulp.task('vscode-linux-x64-prepare-flatpak', ['clean-vscode-linux-x64-flatpak', 'vscode-linux-x64-min'], prepareFlatpak('x64'));
gulp.task('vscode-linux-arm-prepare-flatpak', ['clean-vscode-linux-arm-flatpak', 'vscode-linux-arm-min'], prepareFlatpak('arm'));

gulp.task('vscode-linux-ia32-flatpak', ['vscode-linux-ia32-prepare-flatpak'], buildFlatpak('ia32'));
gulp.task('vscode-linux-x64-flatpak', ['vscode-linux-x64-prepare-flatpak'], buildFlatpak('x64'));
gulp.task('vscode-linux-arm-flatpak', ['vscode-linux-arm-prepare-flatpak'], buildFlatpak('arm'));
<|endoftext|>