Skip to content

Commit

Permalink
Fixed librarian support for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
desertkun committed Jan 10, 2019
1 parent 2808bf3 commit e3bc2f2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ gem 'yard'
gem 'puppet'
gem 'puppet-strings'
gem 'certified'
gem 'librarian-puppet'
gem 'anthill-librarian-puppet'
40 changes: 5 additions & 35 deletions ruby/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
GEM
remote: https://rubygems.org/
specs:
anthill-librarian-puppet (3.0.0)
librarianp (>= 0.6.3)
puppet_forge (~> 2.1)
rsync
certified (1.0.0)
facter (2.5.1)
facter (2.5.1-x64-mingw32)
ffi (~> 1.9.5)
facter (2.5.1-x86-mingw32)
ffi (~> 1.9.5)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fast_gettext (1.1.2)
ffi (1.9.25-x64-mingw32)
ffi (1.9.25-x86-mingw32)
gettext (3.2.9)
locale (>= 2.0.5)
Expand All @@ -24,40 +24,12 @@ GEM
hiera (3.5.0)
hocon (1.2.5)
httpclient (2.8.3)
librarian-puppet (3.0.0)
librarianp (>= 0.6.3)
puppet_forge (~> 2.1)
rsync
librarianp (0.6.4)
thor (~> 0.15)
locale (2.1.2)
minitar (0.6.1)
multi_json (1.13.1)
multipart-post (2.0.0)
puppet (6.1.0)
facter (> 2.0.1, < 4)
fast_gettext (~> 1.1.2)
hiera (>= 3.2.1, < 4)
httpclient (~> 2.8)
locale (~> 2.1)
multi_json (~> 1.10)
puppet-resource_api (~> 1.5)
semantic_puppet (~> 1.0)
puppet (6.1.0-x64-mingw32)
facter (> 2.0.1, < 4)
fast_gettext (~> 1.1.2)
ffi (~> 1.9.25)
hiera (>= 3.2.1, < 4)
httpclient (~> 2.8)
locale (~> 2.1)
minitar (~> 0.6.1)
multi_json (~> 1.10)
puppet-resource_api (~> 1.5)
semantic_puppet (~> 1.0)
win32-dir (= 0.4.9)
win32-process (= 0.7.5)
win32-security (= 0.2.5)
win32-service (= 0.8.8)
puppet (6.1.0-x86-mingw32)
facter (> 2.0.1, < 4)
fast_gettext (~> 1.1.2)
Expand Down Expand Up @@ -101,13 +73,11 @@ GEM
yard (0.9.16)

PLATFORMS
ruby
x64-mingw32
x86-mingw32

DEPENDENCIES
anthill-librarian-puppet
certified
librarian-puppet
puppet
puppet-strings
rdoc
Expand Down
4 changes: 1 addition & 3 deletions src/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,11 @@ export function execFileReadIn(command: string, cwd: string, env?: any, cb?: Exe
{
var str = data.toString(), lines = str.split(/\r?\n/g);

for (let i = lines.length - 1; i >= 0; i--)
for (const line of lines)
{
const line = lines[i];
if (line != "")
{
cb(line);
break;
}
}

Expand Down
56 changes: 44 additions & 12 deletions src/puppet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,20 @@ export module puppet
return null;
}

public static async CallBin(command: string, args: string[], cwd: string, cb?: async.ExecFileLineCallback): Promise<boolean>
public static async CallBin(script: string, args: string[], cwd: string, env: any, cb?: async.ExecFileLineCallback): Promise<boolean>
{
const argsTotal = [
Ruby.Path().rubyPath,
path.join(Ruby.Path().path, command)
path.join(Ruby.Path().path, script)
];

for (let arg of args)
{
argsTotal.push(arg);
}

const env: any = {
"SSL_CERT_FILE": require('app-root-path').resolve("ruby", "cacert.pem"),
"PATH": process.env["PATH"] + path.delimiter + Ruby.Path().path
};

env["SSL_CERT_FILE"] = require('app-root-path').resolve("ruby", "cacert.pem");
env["PATH"] = process.env["PATH"] + path.delimiter + Ruby.Path().path;

try
{
Expand All @@ -64,7 +62,7 @@ export module puppet
}
catch (e)
{
console.log("Failed to execute command " + command + ": " + e);
console.log("Failed to execute command " + script + ": " + e);
return false;
}
}
Expand Down Expand Up @@ -849,14 +847,31 @@ export module puppet

try
{
await Ruby.CallBin("librarian-puppet", ["install", "--verbose"], this._path, (line: string) =>
const lines: string[] = [];

const env: any = {};

if (process.platform == "win32")
{
env["LIBRARIAN_PUPPET_USE_SHORT_CACHE_PATH"] = "true";
env["LIBRARIAN_PUPPET_TMP"] = "C:/";
}

await Ruby.CallBin("librarian-puppet", ["install", "--verbose"], this._path, env, (line: string) =>
{
if (line.length > 80)
{
line = line.substr(0, 80) + " ...";
}

lines.push(line);

if (lines.length > 4)
{
lines.splice(0, 1);
}

if (updateProgressCategory) updateProgressCategory(line, false);
if (updateProgressCategory) updateProgressCategory(lines.join("\n"), false);
});
}
catch (e)
Expand Down Expand Up @@ -1315,14 +1330,31 @@ export module puppet

try
{
await Ruby.CallBin("librarian-puppet", ["install", "--verbose"], this._path, (line: string) =>
const lines: string[] = [];

const env: any = {};

if (process.platform == "win32")
{
env["LIBRARIAN_PUPPET_USE_SHORT_CACHE_PATH"] = "true";
env["LIBRARIAN_PUPPET_TMP"] = "C:/";
}

await Ruby.CallBin("librarian-puppet", ["install", "--verbose"], this._path, env, (line: string) =>
{
if (line.length > 80)
{
line = line.substr(0, 80) + " ...";
}

lines.push(line);

if (lines.length > 4)
{
lines.splice(0, 1);
}

if (updateProgressCategory) updateProgressCategory(line, false);
if (updateProgressCategory) updateProgressCategory(lines.join("\n"), false);
});
}
catch (e)
Expand Down
2 changes: 1 addition & 1 deletion src/windows/workspace/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ export class WorkspaceRenderer
{
$('#workspace-contents').html('<div class="vertical-center h-100"><div><p class="text-center">' +
'<span class="text text-muted"><i class="fas fa-cog fa-4x fa-spin"></i></span></p>' +
'<p class="text-center"><span class="text text-muted" id="loading-category">' +
'<p class="text-center"><span class="text text-muted" style="white-space: pre-line;" id="loading-category">' +
'Please wait while the workspace is updating cache</span></p>' +
'<p class="text-center"><div class="progress" id="loading-progress-p" style="width: 400px;">' +
'<div class="progress-bar progress-bar-striped progress-bar-animated" ' +
Expand Down

0 comments on commit e3bc2f2

Please sign in to comment.