Skip to content

Commit

Permalink
Merge pull request #1 from bitdisaster/64bit_support
Browse files Browse the repository at this point in the history
64bit support
  • Loading branch information
bitdisaster authored Oct 2, 2018
2 parents b2ec275 + 4bc2f68 commit 26449de
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 9 deletions.
54 changes: 54 additions & 0 deletions __tests__/creator-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,57 @@ test('MSICreator compile() throws if signing throws', async () => {
await msiCreator.create();
await expect(msiCreator.compile()).rejects.toEqual(expectedErr);
});

test('MSICreator create() creates x86 version by default', async () => {
const msiCreator = new MSICreator({ ...defaultOptions});

const { wxsFile } = await msiCreator.create();
wxsContent = await fs.readFile(wxsFile, 'utf-8');
console.log(wxsFile);
console.log(wxsContent);
expect(wxsFile).toBeTruthy();
});
testIncludes('32 bit package declaration', 'Platform="x86"');
testIncludes('32 bit component declarations', 'Win64="no"');
testIncludes('32 bit file architecture declaration', 'ProcessorArchitecture="x86"');

test('MSICreator create() creates x86 version explicitly', async () => {
const msiCreator = new MSICreator({ ...defaultOptions, arch: 'x86'});

const { wxsFile } = await msiCreator.create();
wxsContent = await fs.readFile(wxsFile, 'utf-8');
console.log(wxsFile);
console.log(wxsContent);
expect(wxsFile).toBeTruthy();
});
testIncludes('32 bit package declaration', 'Platform="x86"');
testIncludes('32 bit component declarations', 'Win64="no"');
testIncludes('32 bit file architecture declaration', 'ProcessorArchitecture="x86"');

test('MSICreator create() creates x64 version', async () => {
const msiCreator = new MSICreator({ ...defaultOptions, arch: 'x64'});

const { wxsFile } = await msiCreator.create();
wxsContent = await fs.readFile(wxsFile, 'utf-8');
console.log(wxsFile);
console.log(wxsContent);
expect(wxsFile).toBeTruthy();
});
testIncludes('32 bit package declaration', 'Platform="x64"');
testIncludes('32 bit component declarations', 'Win64="yes"');
testIncludes('32 bit file architecture declaration', 'ProcessorArchitecture="x64"');

test('MSICreator create() creates ia64 version', async () => {
const msiCreator = new MSICreator({ ...defaultOptions, arch: 'ia64'});

const { wxsFile } = await msiCreator.create();
wxsContent = await fs.readFile(wxsFile, 'utf-8');
console.log(wxsFile);
console.log(wxsContent);
expect(wxsFile).toBeTruthy();
});
testIncludes('32 bit package declaration', 'Platform="ia64"');
testIncludes('32 bit component declarations', 'Win64="yes"');
testIncludes('32 bit file architecture declaration', 'ProcessorArchitecture="ia64"');


20 changes: 16 additions & 4 deletions src/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface MSICreatorOptions {
signWithParams?: string;
certificateFile?: string;
certificatePassword?: string;
arch?: 'x64' | 'ia64'| 'x86';
}

export interface UIOptions {
Expand Down Expand Up @@ -81,6 +82,7 @@ export class MSICreator {
public certificateFile?: string;
public certificatePassword?: string;
public signWithParams?: string;
public arch: 'x64' | 'ia64'| 'x86' = 'x86';

public ui: UIOptions | boolean;

Expand All @@ -106,6 +108,7 @@ export class MSICreator {
this.signWithParams = options.signWithParams;
this.upgradeCode = options.upgradeCode || uuid();
this.version = options.version;
this.arch = options.arch || 'x86';

this.appUserModelId = options.appUserModelId
|| `com.squirrel.${this.shortName}.${this.exe}`;
Expand Down Expand Up @@ -178,6 +181,13 @@ export class MSICreator {
const directories = await this.getDirectoryForTree(
this.tree, base, 8, ROOTDIR_NAME, this.programFilesFolderName);
const componentRefs = await this.getComponentRefs();

const scaffoldReplacements = {
'<!-- {{ComponentRefs}} -->': componentRefs.map(({ xml }) => xml).join('\n'),
'<!-- {{Directories}} -->': directories,
'<!-- {{UI}} -->': this.getUI()
};

const replacements = {
'{{ApplicationBinary}}': this.exe,
'{{ApplicationDescription}}': this.description,
Expand All @@ -190,12 +200,14 @@ export class MSICreator {
'{{ShortcutFolderName}}': this.shortcutFolderName,
'{{UpgradeCode}}': this.upgradeCode,
'{{Version}}': this.version,
'<!-- {{ComponentRefs}} -->': componentRefs.map(({ xml }) => xml).join('\n'),
'<!-- {{Directories}} -->': directories,
'<!-- {{UI}} -->': this.getUI()
'{{Platform}}': this.arch,
'{{ProgramFilesFolder}}': this.arch === 'x86' ? 'ProgramFilesFolder' : 'ProgramFiles64Folder',
'{{ProcessorArchitecture}}' : this.arch,
'{{Win64YesNo}}' : this.arch === 'x86' ? 'no' : 'yes',
};

const output = await replaceToFile(this.wixTemplate, target, replacements);
const completeTemplate = replaceInString(this.wixTemplate, scaffoldReplacements);
const output = await replaceToFile(completeTemplate, target, replacements);

return { wxsFile: target, wxsContent: output };
}
Expand Down
4 changes: 2 additions & 2 deletions static/component.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- {{I}} --><Component Id="{{ComponentId}}" Guid="{{Guid}}">
<!-- {{I}} --> <File Name="{{Name}}" Id="{{FileId}}" Source="{{SourcePath}}" KeyPath="yes" Checksum="yes"/>
<!-- {{I}} --><Component Id="{{ComponentId}}" Guid="{{Guid}}" Win64="{{Win64YesNo}}">
<!-- {{I}} --> <File Name="{{Name}}" Id="{{FileId}}" Source="{{SourcePath}}" KeyPath="yes" Checksum="yes" ProcessorArchitecture="{{ProcessorArchitecture}}"/>
<!-- {{I}} --></Component>
7 changes: 4 additions & 3 deletions static/wix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<Package InstallerVersion="405"
Compressed="yes"
InstallScope="perMachine"
Comments="Windows Installer Package"/>
Comments="Windows Installer Package"
Platform="{{Platform}}"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>

<!-- Handle Updates -->
Expand All @@ -32,7 +33,7 @@
<!-- Step 2: Add files and directories -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- Installation files to %PROGRAMFILES% -->
<Directory Id="ProgramFilesFolder">
<Directory Id="{{ProgramFilesFolder}}">
<!-- {{Directories}} -->
</Directory>
<!-- Start Menu -->
Expand All @@ -43,7 +44,7 @@

<!-- Step 3: Add app to Start Menu -->
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="{{ApplicationShortcutGuid}}">
<Component Id="ApplicationShortcut" Guid="{{ApplicationShortcutGuid}}" Win64='{{Win64YesNo}}'>
<Shortcut Id="ApplicationStartMenuShortcut"
Name="{{ApplicationName}}"
Description="{{ApplicationDescription}}"
Expand Down

0 comments on commit 26449de

Please sign in to comment.